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,46 +1,48 @@
|
|||
<story title="Richard and Larry Build A Time Machine" author="Jeremy Penner">
|
||||
<loadmodule url="retrochronal.js" />
|
||||
<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>
|
||||
</nev>
|
||||
<word name="DeLorean">
|
||||
<verb name="Examine">
|
||||
Larry looks at the [DeLorean] with astonishment. [Richard] has done it up to look <i>exactly</i> like the car from
|
||||
<i>Back to the Future</i>.
|
||||
</verb>
|
||||
<verb name="Drive">
|
||||
<p>Larry eyes the [DeLorean car]. "Give me the keys," he says. "I want to take this baby to 88."</p>
|
||||
<p>"Oh, it doesn't drive anymore," says [Richard]. "I had to use the engine to power the time machine."</p>
|
||||
</verb>
|
||||
</word>
|
||||
<word name="Richard">
|
||||
<verb name="how" display="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>
|
||||
<p>"Right."</p>
|
||||
<p>Larry ponders this for a moment. "How... how does that even work?"</p>
|
||||
<p>[Richard] waves his hands around. "Spooky action at a distance," he says.</p>
|
||||
<p>"No, I mean, augh. I mean, what can you practically change about the past with this machine?" says Larry.</p>
|
||||
<p>
|
||||
"Well, so far I've gotten my computer to crash five minutes before I push this [button]," says [Richard],
|
||||
gesturing at one of the controls inside the [DeLorean].
|
||||
</p>
|
||||
</verb>
|
||||
</word>
|
||||
<word name="button">
|
||||
<verb name="Push">
|
||||
<p>Larry reaches for the button and gives it a push.</p>
|
||||
<p>"Nothing happened", says Larry, looking at the [computer].</p>
|
||||
<p>"I <i>told</i> you you were going to push it," says [Richard].</p>
|
||||
<p>Larry opens his mouth to say something, then seems to think better of it.</p>
|
||||
</verb>
|
||||
</word>
|
||||
<pastresponse after="start" future_cause="button.Push" name="crash">
|
||||
<p>There is a beep as [Richard Richard's] [computer] spontaneously and inexplicably reboots.</p>
|
||||
<p>"Aw, geez, you're going to push the button, aren't you?", whines [Richard].</p>
|
||||
<p>"What? What button?" asks Larry, puzzled.</p>
|
||||
<p>"Never mind," says [Richard].</p>
|
||||
</pastresponse>
|
||||
<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>
|
||||
</nev>
|
||||
<word name="DeLorean">
|
||||
<verb name="Examine">
|
||||
Larry looks at the [DeLorean] with astonishment. [Richard] has done it up to look <i>exactly</i> like the car from
|
||||
<i>Back to the Future</i>.
|
||||
</verb>
|
||||
<verb name="Drive">
|
||||
<p>Larry eyes the [DeLorean car]. "Give me the keys," he says. "I want to take this baby to 88."</p>
|
||||
<p>"Oh, it doesn't drive anymore," says [Richard]. "I had to use the engine to power the time machine."</p>
|
||||
</verb>
|
||||
</word>
|
||||
<word name="Richard">
|
||||
<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>
|
||||
<p>"Right."</p>
|
||||
<p>Larry ponders this for a moment. "How... how does that even work?"</p>
|
||||
<p>[Richard] waves his hands around. "Spooky action at a distance," he says.</p>
|
||||
<p>"No, I mean, augh. I mean, what can you practically change about the past with this machine?" says Larry.</p>
|
||||
<p>
|
||||
"Well, so far I've gotten my computer to crash five minutes before I push this [button]," says [Richard],
|
||||
gesturing at one of the controls inside the [DeLorean].
|
||||
</p>
|
||||
</verb>
|
||||
</word>
|
||||
<word name="button">
|
||||
<verb name="Push">
|
||||
<p>Larry reaches for the button and gives it a push.</p>
|
||||
<p>"Nothing happened", says Larry, looking at the [computer].</p>
|
||||
<p>"I <i>told</i> you you were going to push it," says [Richard].</p>
|
||||
<p>Larry opens his mouth to say something, then seems to think better of it.</p>
|
||||
</verb>
|
||||
</word>
|
||||
<pastresponse after="start" future_cause="button.Push" name="crash">
|
||||
<p>There is a beep as [Richard Richard's] [computer] spontaneously and inexplicably reboots.</p>
|
||||
<p>"Aw, geez, you're going to push the button, aren't you?", whines [Richard].</p>
|
||||
<p>"What? What button?" asks Larry, puzzled.</p>
|
||||
<p>"Never mind," says [Richard].</p>
|
||||
</pastresponse>
|
||||
</section>
|
||||
</story>
|
||||
|
|
Loading…
Reference in a new issue