fix(rules): allow a free weapon draw with a move at BAB +1

SRD 'Move Actions': 'If you have a base attack bonus of +1 or higher, you may draw a weapon as a free action combined with a regular move.' _filter_turn_actions computes free_draw (BAB >= 1 AND a move action in the turn sequence) and threads it through _effective_slot/_action_economy_filter/_staggered_filter: retrieve_weapon then occupies the free slot instead of the move slot. Static classification stays 'move' (repair_weapon and no-move draws unchanged). Filter-level and engine-level (BAB +2 vs BAB 0) tests added.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-09-12 14:35:42 +02:00
parent 317c68ecdb
commit 25149c64ba
4 changed files with 124 additions and 10 deletions
+27
View File
@@ -362,6 +362,33 @@ def test_staggered_filter_keeps_withdraw_as_restricted_standard() -> None:
assert _staggered_filter((_foe("withdraw"), _foe("attack"))) == (_foe("withdraw"),)
def test_free_draw_with_a_move_at_bab_plus1() -> None:
# SRD "Move Actions": "If you have a base attack bonus of +1 or higher,
# you may draw a weapon as a free action combined with a regular move."
# With the engine's free_draw flag set (BAB >= 1 AND a move in sequence),
# retrieve_weapon does not consume the move slot — the standard stays
# available for the attack.
actions = (_foe("move"), _foe("retrieve_weapon"), _foe("attack"))
assert _action_economy_filter(actions, free_draw=True) == actions
# Without the free draw the retrieve spends the move slot, converts the
# standard slot (move-slot conversion) and the attack is surplus.
kept_no_free = _action_economy_filter(actions, free_draw=False)
assert tuple(a.kind for a in kept_no_free) == ("move", "retrieve_weapon")
# A second standard after a free draw is surplus: the move slot was
# taken by the move, the standard by the first attack.
kept = _action_economy_filter(
(_foe("move"), _foe("retrieve_weapon"), _foe("attack"), _foe("attack")),
free_draw=True,
)
assert tuple(a.kind for a in kept) == ("move", "retrieve_weapon", "attack")
# Without a move in the sequence the engine never sets free_draw; the
# retrieve then spends the move slot itself and the attack is surplus.
kept_no_move = _action_economy_filter(
(_foe("retrieve_weapon"), _foe("attack")), free_draw=False
)
assert tuple(a.kind for a in kept_no_move) == ("retrieve_weapon", "attack")
def test_nauseated_after_budget_keeps_single_move() -> None:
# (move, attack, move): the budget drops the second move; the nauseated
# filter then keeps only the first move and drops the standard attack.
+56
View File
@@ -159,3 +159,59 @@ def _run_with_retrieve() -> tuple[str, ...]:
def test_determinism_same_seed_same_transcript() -> None:
assert _run_with_retrieve() == _run_with_retrieve()
# --- Test 6: free draw combined with a move at BAB +1 ------------------------
def _move_retrieve_attack_run(bab: int) -> CombatEngine:
a_spec = make_combatant("a", attack_bonus=bab)
b_spec = make_combatant("b")
a = make_state(a_spec, "players", (1, 1))
b = make_state(b_spec, "monsters", (1, 4))
a.weapon_stolen.add("a-w")
def policy(engine: CombatEngine, state: CombatantState) -> tuple[Action, ...]:
if state.combatant.id == "a":
return (
Action(kind="move", target_id="b"),
Action(kind="retrieve_weapon", weapon_id="a-w"),
Action(kind="attack", target_id="b"),
)
return (Action(kind="wait"),)
engine = CombatEngine(
ScriptedRng([10, 5, 10, 3]), make_grid(), [a, b], policy=policy, round_cap=1
)
engine.run()
return engine
def test_bab_plus1_draws_for_free_and_still_attacks() -> None:
# SRD "Move Actions": "If you have a base attack bonus of +1 or higher,
# you may draw a weapon as a free action combined with a regular move."
# Given: a BAB +2 combatant whose turn sequence is (move, retrieve, attack)
# When: the turn runs
# Then: all three actions execute — the draw rides the move for free and
# the standard attack still happens.
engine = _move_retrieve_attack_run(bab=2)
a = engine._states[0]
assert not a.weapon_stolen
kinds = [(r.kind, r.ok) for r in a.last_action_results]
assert ("move", True) in kinds
assert ("retrieve_weapon", True) in kinds
assert ("attack", True) in kinds
assert any(" vs b " in line for line in engine._transcript)
def test_bab_zero_draw_still_costs_the_standard_slot() -> None:
# Given: the same sequence but BAB 0 — the draw is a move action, which
# converts the standard slot, leaving nothing for the attack.
# Then: the attack is downgraded out.
engine = _move_retrieve_attack_run(bab=0)
a = engine._states[0]
assert not a.weapon_stolen
assert any(
r.kind == "attack" and r.reason == "downgraded:action_economy"
for r in a.last_action_results
)