Skip to content

Commit 8924617

Browse files
committed
Merge All rules in order, focus and the references' tips
2 parents 33be747 + e9d2496 commit 8924617

16 files changed

Lines changed: 892 additions & 117 deletions

‎apps/studio/README.md‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,28 @@ starting where the last stood, facing as it faced, and the Timeline's bar above
8989
shows the steps (click one to pick it). Picking or playing anything else starts clips where
9090
they normally start.
9191

92-
The Behaviour tab beside the 3D view (the button under the moves, or View > Panels) draws the
93-
port's `[behaviour]` graph: every move and block is a node, and right-click adds a block (the
94-
palette is `mhfu_port.behaviour.KINDS`). A wire from a block's `out` feeds the next block's `in`,
95-
or plays a move at its `play`; a move's `while playing` starts a path while it plays, and its
96-
`then` hands to another move (`after`). Any other wire is refused in the status line. `#2` is a
97-
block's path rank (higher on the canvas is checked first, but every path that plays nothing runs
98-
before all the others), `⚠` a path the game refuses (the tip says why), faded a block on no
99-
complete path. Delete removes blocks and their links; a move is
100-
deleted in Moves. Every gesture is one undo step. The tab has no docks until you open one on it,
101-
and keeps them apart from the 3D view's; Findings stays open across tabs.
92+
The Behaviour tab beside the 3D view (the button under the moves, or View > Panels) edits the
93+
port's `[behaviour]` graph as rules. The outline on the left lists what starts a rule: an event,
94+
a state between moves, or a move playing, each with its rule count and ranks; pick one and its
95+
rules are rows, or pick All rules for every one. A row is a frame titled `#rank · trigger · note`,
96+
in the order the game checks them (`#1` first; rules that play nothing go first): the rule's blocks left to right, then the move
97+
it plays as a dashed reference (`×n` when n rules play it) whose tip names those rules and the
98+
move's `then` sequence. A block or reference you select is edited in the bar below: its params
99+
and note, the move a reference plays, and Play, which plays the move in the game and is off,
100+
with the reason in its tip, when it cannot. `+ Rule` adds a rule checked last; right-click a
101+
block to insert one after it or delete it, and drag a frame to reorder it among its trigger's
102+
rules (in All, among its own trigger's only; the status says so). `⚠` marks a rule the game
103+
refuses (the tip says why). Every gesture is one undo step.
104+
105+
All rules has a header toggle: In order (the default, kept per document) shows every rule as a
106+
row, each starting with its trigger, and Canvas shows the stored graph as a free canvas.
107+
Right-click adds a block (the palette is `mhfu_port.behaviour.KINDS`); a wire from a block's `out`
108+
feeds the next block's `in`, or plays a move at its `play`; a move's `while playing` starts a rule
109+
while it plays, and its `then` hands to another move (`after`); any other wire is refused in the
110+
status line. Selecting a node dims all but the rules through it. Spread out loosens the layout, a
111+
faded block is on no complete rule, and rows write no block position. A move is deleted in Moves.
112+
The tab has no docks until you open one on it, and keeps them apart from the 3D view's; Findings
113+
stays open across tabs.
102114

103115
Effect blocks (violet) change the monster's counters and flags when their path fires. A path may
104116
end at an effect with nothing to play: it applies its effects, keeps its `#n` on that block, and

‎apps/studio/src/mhfu_studio/monster/behaviour.py‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"""A move node's ports: the input, then the two outputs."""
3232
ALL = "all"
3333
"""The scope that is the whole canvas, as stored; any other is a trigger's key."""
34+
ORDER, CANVAS = "order", "canvas"
35+
"""What All shows: every rule as a framed row in the order they are checked, or the canvas as
36+
stored."""
3437
INSERTABLE = ("condition", "modifier", "effect")
3538
"""The roles of the blocks a rule holds besides its first."""
3639
ROLE_TITLES = {"state": "State"}
@@ -141,6 +144,48 @@ def wires(m: Manifest) -> list[Wire]:
141144
return out
142145

143146

147+
class Focus(NamedTuple):
148+
"""What stays bright when nodes are selected."""
149+
150+
nodes: frozenset[str]
151+
wires: frozenset[Wire]
152+
153+
154+
def focus(m: Manifest, ps: Sequence[Path], ids: Collection[str]) -> Focus | None:
155+
"""The rules through `ids`, whole, with the moves each hands on to; the nodes `ids` always.
156+
None when nothing is selected."""
157+
if not ids:
158+
return None
159+
nodes, lit = set(ids), set[Wire]()
160+
for p in ps:
161+
names = sequence.chain(m, p.play) if p.play else []
162+
steps = [move_id(n) for n in names]
163+
start = [move_id(p.during)] if p.during else []
164+
if not {*start, *p.blocks, *steps} & set(ids):
165+
continue
166+
lit.update(Wire(a, OUT, b, IN) for a, b in zip(p.blocks, p.blocks[1:], strict=False))
167+
if start:
168+
lit.add(Wire(start[0], WHILE, p.blocks[0], IN))
169+
if steps:
170+
lit.add(Wire(p.blocks[-1], OUT, steps[0], PLAY))
171+
lit.update(
172+
Wire(move_id(n), THEN, move_id(after), PLAY)
173+
for n in names
174+
if (after := m.moves[n].after) in m.moves
175+
)
176+
nodes.update(start, p.blocks, steps)
177+
return Focus(frozenset(nodes), frozenset(lit))
178+
179+
180+
def then(m: Manifest, name: str) -> list[str]:
181+
"""The moves `name` hands to in turn; a sequence that rings ends with the move it hands back
182+
to."""
183+
steps = sequence.chain(m, name)[1:]
184+
last = steps[-1] if steps else name
185+
back = m.moves[last].after if last in m.moves else None
186+
return [*steps, *([back] if back else [])]
187+
188+
144189
def spots(m: Manifest) -> dict[str, Point]:
145190
"""Where each move sits: its node's place, else a column right of everything placed, in
146191
sequence order so a chain sits together."""

0 commit comments

Comments
 (0)