kliffy/retrochronal.coffee

35 lines
1.3 KiB
CoffeeScript
Raw Normal View History

2010-12-02 01:04:15 +00:00
###
RetroChronal -- an iffy module for violating causality
Usage:
<pastresponse after="nev" future_cause="nev" [name="name"]>
nev text
</pastresponse>
where the nev specified in "after" is the one that this nev should appear after, and the nev specified in future_cause is the one
that causes this nev to happen in the future. If the nev specified in future_cause doesn't appear, this nev will not be displayed.
###
class ActorRetro
constructor: (@story) ->
@mpnevID_rgnevResponse = {}
for dResponse in @story.jStory.find("pastresponse")
@add(@story.NevByName($(dResponse).attr("after")), dResponse)
add: (nev, dResponse) ->
if not @mpnevID_rgnevResponse[nev.ID()]?
@mpnevID_rgnevResponse[nev.ID()] = []
@mpnevID_rgnevResponse[nev.ID()].push(new Nev($(dResponse)))
EninevResponse: (nev, wst) ->
rgnevTest = @mpnevID_rgnevResponse[nev.ID()]
if rgnevTest?
FKeepNevTest = (nevTest, eniNev, nevgen, respo) ->
nevFuture = nevgen.wst.gst.story.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)
else
EniEmpty
FilterStHtml: (stHtml, wst) -> stHtml
return (gst) ->
gst.story.rgactor.splice(0, 0, new ActorRetro(gst.story))