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:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user