kliffy/retrochronal.coffee

36 lines
1.4 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 = {}
2011-02-15 01:26:48 +00:00
for section in @story.Rgsection()
for dResponse in section.jSection.find("pastresponse")
@add(section.NevByName($(dResponse).attr("after")), dResponse)
2010-12-02 01:04:15 +00:00
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) ->
2011-02-15 01:26:48 +00:00
nevFuture = nevgen.wst.gst.SectionCurrent().NevByName($(nevTest.dNev).attr("future_cause"))
2010-12-02 01:04:15 +00:00
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))