initial support for sections
This commit is contained in:
parent
13e0166667
commit
c45e3cf00d
36
iffy.coffee
36
iffy.coffee
|
@ -141,10 +141,19 @@ class Nevgen
|
|||
# game state -- holds all the information needed to display the current state of the game in our browser
|
||||
class Gst
|
||||
constructor: (@story, @jDiv) ->
|
||||
@wstInit = @story.WstInit(this)
|
||||
@rgwstInit = [@story.WstInit(this)]
|
||||
@rgsection = [@story.SectionByName("start")]
|
||||
@rgwst = null
|
||||
@igenID = 0
|
||||
|
||||
GoBackOneSection: () ->
|
||||
isectionRemove = @rgsection.length - 1
|
||||
@rgsection.splice(isectionRemove, 1)
|
||||
@rgwstInit.splice(isectionRemove, 1)
|
||||
|
||||
SectionCurrent: () ->
|
||||
@rgsection[@rgsection.length - 1]
|
||||
|
||||
Display: () ->
|
||||
@mpstId_dgOnClick = []
|
||||
@ClearMenu(true)
|
||||
|
@ -207,7 +216,7 @@ class Gst
|
|||
stId
|
||||
|
||||
RgwstRun: () ->
|
||||
wst = @wstInit.WstNext(@story.NevByName("start"))
|
||||
wst = @rgwstInit[@rgwstInit.length - 1].WstNext(@SectionCurrent().NevByName("start"))
|
||||
eniWst = Nevgen.EniWst(this, wst)
|
||||
ArrayFromEni(eniWst)
|
||||
|
||||
|
@ -360,7 +369,7 @@ TemplateFromStNev = (st, wst) ->
|
|||
else
|
||||
stDisplay = rgstDisplay[1].replace(/_/g, " ")
|
||||
|
||||
word = wst.gst.story.WordByName(wst.gst, stWord)
|
||||
word = wst.gst.SectionCurrent().WordByName(wst.gst, stWord)
|
||||
if word? and (rgverb = word.Rgverb(wst)).length > 0
|
||||
dgOnClick = (ev) -> wst.gst.ShowMenu(ev, this, rgverb)
|
||||
|
||||
|
@ -448,10 +457,23 @@ class Story
|
|||
constructor: (@jStory) ->
|
||||
@actorPlayer = new ActorPlayer(this)
|
||||
@rgactor = [@actorPlayer]
|
||||
SectionByName: (stName) ->
|
||||
jSection = @jStory.find("section[name=#{stName}]")
|
||||
if jSection.length == 1 then new Section(this, jSection)
|
||||
Rgsection: () ->
|
||||
new Section(this, $(jSection)) for jSection in @jStory.find("section").toArray()
|
||||
RespoResponse: (nev, wst) ->
|
||||
Respo.FromEnieniNev(new EniMap(new EniArray(@rgactor), (actor) -> actor.EninevResponse(nev, wst)))
|
||||
WstInit: (gst) ->
|
||||
NewWst({}, gst)
|
||||
|
||||
class Section
|
||||
constructor: (@story, @jSection) ->
|
||||
|
||||
NevByName: (stName) ->
|
||||
if stName?
|
||||
rgstName = stName.split('.')
|
||||
for dNev in @jStory.find("[name=#{rgstName[rgstName.length - 1]}]")
|
||||
for dNev in @jSection.find("[name=#{rgstName[rgstName.length - 1]}]")
|
||||
istName = rgstName.length - 2
|
||||
dParent = dNev
|
||||
while dParent? and istName >= 0
|
||||
|
@ -461,12 +483,8 @@ class Story
|
|||
return new Nev(dNev)
|
||||
null
|
||||
WordByName: (gst, stName) ->
|
||||
jWord = @jStory.find("word[name=#{stName}]")
|
||||
jWord = @jSection.find("word[name=#{stName}]")
|
||||
if jWord.length > 0 then new Word(gst, jWord)
|
||||
RespoResponse: (nev, wst) ->
|
||||
Respo.FromEnieniNev(new EniMap(new EniArray(@rgactor), (actor) -> actor.EninevResponse(nev, wst)))
|
||||
WstInit: (gst) ->
|
||||
NewWst({}, gst)
|
||||
|
||||
Rgget = (rgurl, dgAfter, iurl, rgresult) ->
|
||||
if not iurl? then iurl = 0
|
||||
|
|
|
@ -13,8 +13,9 @@ that causes this nev to happen in the future. If the nev specified in future_ca
|
|||
class ActorRetro
|
||||
constructor: (@story) ->
|
||||
@mpnevID_rgnevResponse = {}
|
||||
for dResponse in @story.jStory.find("pastresponse")
|
||||
@add(@story.NevByName($(dResponse).attr("after")), dResponse)
|
||||
for section in @story.Rgsection()
|
||||
for dResponse in section.jSection.find("pastresponse")
|
||||
@add(section.NevByName($(dResponse).attr("after")), dResponse)
|
||||
add: (nev, dResponse) ->
|
||||
if not @mpnevID_rgnevResponse[nev.ID()]?
|
||||
@mpnevID_rgnevResponse[nev.ID()] = []
|
||||
|
@ -23,7 +24,7 @@ class ActorRetro
|
|||
rgnevTest = @mpnevID_rgnevResponse[nev.ID()]
|
||||
if rgnevTest?
|
||||
FKeepNevTest = (nevTest, eniNev, nevgen, respo) ->
|
||||
nevFuture = nevgen.wst.gst.story.NevByName($(nevTest.dNev).attr("future_cause"))
|
||||
nevFuture = nevgen.wst.gst.SectionCurrent().NevByName($(nevTest.dNev).attr("future_cause"))
|
||||
return nevFuture? and nevgen.wst.gst.FWillNevRun(nevgen.wst, new EniFilter(eniNev, FKeepNevTest), nevgen, respo, nevTest, nevFuture)
|
||||
|
||||
new EniFilter(new EniArray(rgnevTest), FKeepNevTest)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<story title="Richard and Larry Build A Time Machine" author="Jeremy Penner">
|
||||
<loadmodule url="retrochronal.js" />
|
||||
<section name="start">
|
||||
<nev name="start">
|
||||
<p>"I still can't believe you actually used a [DeLorean]," says Larry.</p>
|
||||
<p>"Hey, if you're going to do a thing, you ought to do it right," says [Richard].</p>
|
||||
|
@ -15,7 +16,7 @@
|
|||
</verb>
|
||||
</word>
|
||||
<word name="Richard">
|
||||
<verb name="how" display="What have you done?">
|
||||
<verb name="how" display='Say, "What have you done?"'>
|
||||
<p>"So, run it by me again," says Larry.</p>
|
||||
<p>"I modified this [DeLorean] to send information backwards through time," says [Richard].</p>
|
||||
<p>"Just information. Not matter."</p>
|
||||
|
@ -43,4 +44,5 @@
|
|||
<p>"What? What button?" asks Larry, puzzled.</p>
|
||||
<p>"Never mind," says [Richard].</p>
|
||||
</pastresponse>
|
||||
</section>
|
||||
</story>
|
||||
|
|
Loading…
Reference in a new issue