I followed this tutorial while implementing a basic combat system (adapting the Harlowe to Sugarcube) and now I'm working on fleshing it out. The problem I'm having is that this model uses nested passages to achieve a look of discrete display windows:
Passage Combat, the parent passage:
<<include "Enemy">>
<<include "Log">>
<<include "You">>
Passage Enemy, a child passage:
<div id="enemy">$ename HP: $ehp/$mhp</div>
Passage Log, a child passage:
<div id="log">
<<if $log is "you">>
It is your turn.
<<elseif $log is "atk">>
You use '$atk' on the $ename, dealing $atkdmg damage.
<<elseif $log is "enemy">>
The $ename uses '$eatkname' on you, dealing $eatk damage.
<</if>>
</div>
Passage You, a child passage:
<div id="you">
You: $hp/100
<<if $turn is "you">>
<<link "Punch"->Combat)
<<set $ehp -= 10>>
<<set $atk to "Punch">>
<<set $atkdmg to 10>>
<<set $turn to "enemy">>
<<set $log to "atk">>
<</link>>
<<link "Sword"->Combat>>
<<set $ehp -= 30>>
<<set $atk to "Sword">>
<<set $atkdmg to 30>>
<<set $turn to "enemy">>
<<set $log to "atk">>
<</link>>
<<elseif $turn is "enemy">>
<<link "Continue"->Combat>>
<<set $log to "enemy">>
<<set $turn to "you">>
<<set $hp -= $eatk>>
<</link>>
<</if>>
<<if $hp < 1>><<goto "CombatLose">><</if>>
<<if $ehp < 1>><<goto "CombatWin">><</if>>
</div>
This model relies on routing the user back through the parent Combat passage and re-including the child passages to update their displayed data. It can be very awkward to route and re-route the user through the parent Combat passage in order to update child passages' text whenever data changes -- is there a way to tell a given Passage object that it should re-render itself because underlying data has changed?