Skip to content

Commit f914df7

Browse files
sp00ktoberclaude
andcommitted
fix(studio): a rule that plays nothing by design ends at its last block
Only a rule with no move yet ends in the placeholder; a rule that plays nothing on purpose, which a later kind of block allows, keeps its last block as its end. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 67abf52 commit f914df7

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎apps/studio/src/mhfu_studio/monster/panels/rows.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def plan(
142142
links += [LinkSpec(a, graph.OUT, b, graph.IN) for a, b in zip(ids, ids[1:], strict=False)]
143143
if start is not None:
144144
links.append(LinkSpec(start.id, graph.WHILE, ids[0], graph.IN))
145+
end: NodeSpec | None = None
145146
if p.play:
146147
by = played.get(p.play, ())
147148
end = NodeSpec(
@@ -155,7 +156,7 @@ def plan(
155156
f"rule{'' if len(by) == 1 else 's'}: " + ", ".join(f"#{k}" for k in by),
156157
ref=True,
157158
)
158-
else:
159+
elif rank is None: # a rule that plays nothing by design ends at its last block
159160
end = NodeSpec(
160161
f"{OPEN}{ids[-1]}",
161162
PLACEHOLDER,
@@ -166,8 +167,9 @@ def plan(
166167
" in the bar",
167168
ref=True,
168169
)
169-
nodes.append(end)
170-
links.append(LinkSpec(ids[-1], graph.OUT, end.id, graph.PLAY))
170+
if end is not None:
171+
nodes.append(end)
172+
links.append(LinkSpec(ids[-1], graph.OUT, end.id, graph.PLAY))
171173
if rank is None:
172174
news[p.blocks[0]] += 1
173175
frame, title = f"{FRAME}{NEW}:{p.blocks[0]}:{news[p.blocks[0]]}", UNFINISHED

‎apps/studio/tests/monster/ui/test_triggers.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ def test_a_rule_with_no_move_yet_ends_in_a_placeholder_after_the_others() -> Non
284284
assert plan.row_of("nope") is None
285285

286286

287+
def test_a_rule_that_plays_nothing_by_design_ends_at_its_last_block() -> None:
288+
plan = rows.plan(trigger(Path(("b1", "b2"), "", None)), BLOCKS, NOTES, MOVES, {})
289+
assert [n.id for n in plan.rows[0].nodes] == ["b1", "b2"] and len(plan.links) == 1
290+
assert plan.rows[0].rank == 1
291+
292+
287293
def test_a_while_trigger_starts_from_its_move_once() -> None:
288294
t = trigger(Path(("b1",), "n", "m"), Path(("b3",), "n", "m"), section="move", name="m")
289295
plan = rows.plan(t, BLOCKS, NOTES, MOVES, {"n": (1, 2)})

0 commit comments

Comments
 (0)