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:
@@ -1625,7 +1625,16 @@ class CombatEngine:
|
||||
for _ in range(len(actions) - len(schedulable))
|
||||
)
|
||||
actions = schedulable
|
||||
kept = _action_economy_filter(actions, cast_time=self._cast_time_of)
|
||||
# PF1e (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." The draw rides the turn's move action instead of
|
||||
# consuming the move slot.
|
||||
free_draw = state.combatant.bab >= 1 and any(
|
||||
a.kind == "move" for a in actions
|
||||
)
|
||||
kept = _action_economy_filter(
|
||||
actions, cast_time=self._cast_time_of, free_draw=free_draw
|
||||
)
|
||||
results.extend(
|
||||
ActionResult(
|
||||
kind=kind, ok=False, reason=_REASON_DOWNGRADED_ACTION_ECONOMY
|
||||
@@ -1642,7 +1651,9 @@ class CombatEngine:
|
||||
actions = kept
|
||||
state.immediate_used = False
|
||||
if self._is_staggered_limited(state):
|
||||
kept = _staggered_filter(actions, cast_time=self._cast_time_of)
|
||||
kept = _staggered_filter(
|
||||
actions, cast_time=self._cast_time_of, free_draw=free_draw
|
||||
)
|
||||
results.extend(
|
||||
ActionResult(kind=kind, ok=False, reason=_REASON_DOWNGRADED_STAGGERED)
|
||||
for kind in _dropped_kinds(actions, kept)
|
||||
@@ -6790,13 +6801,24 @@ def _cast_time_slot(cast_time: CastTime) -> _ActionEconomySlot:
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
def _effective_slot(action: Action, cast_time: CastTimeResolver) -> _ActionEconomySlot:
|
||||
def _effective_slot(
|
||||
action: Action, cast_time: CastTimeResolver, *, free_draw: bool = False
|
||||
) -> _ActionEconomySlot:
|
||||
"""The budget slot an action consumes, resolving cast_spell by cast time
|
||||
and the cackle hex by its APG free-action cost."""
|
||||
and the cackle hex by its APG free-action cost.
|
||||
|
||||
``free_draw`` (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") makes retrieve_weapon occupy the free slot instead of the move
|
||||
slot — the caller sets it only when the turn's sequence carries a move
|
||||
action and the actor's BAB is at least +1.
|
||||
"""
|
||||
if action.kind == "cast_spell":
|
||||
return _cast_time_slot(cast_time(action))
|
||||
if action.kind == "hex" and action.hex_name == "cackle":
|
||||
return "free"
|
||||
if action.kind == "retrieve_weapon" and free_draw:
|
||||
return "free"
|
||||
return _action_economy_slot(action.kind)
|
||||
|
||||
|
||||
@@ -6831,6 +6853,7 @@ def _staggered_filter(
|
||||
actions: tuple[Action, ...],
|
||||
*,
|
||||
cast_time: CastTimeResolver = _default_cast_time,
|
||||
free_draw: bool = False,
|
||||
) -> tuple[Action, ...]:
|
||||
"""Staggered: one move OR one standard action, plus every swift and free.
|
||||
|
||||
@@ -6859,7 +6882,7 @@ def _staggered_filter(
|
||||
kept.append(Action(kind="attack", target_id=action.target_id))
|
||||
slot_used = True
|
||||
continue
|
||||
slot = _effective_slot(action, cast_time)
|
||||
slot = _effective_slot(action, cast_time, free_draw=free_draw)
|
||||
if slot == "full_round":
|
||||
if action.kind == "withdraw" and not slot_used:
|
||||
# Restricted Withdraw: standard action, move up to speed.
|
||||
@@ -6950,6 +6973,7 @@ def _action_economy_filter(
|
||||
actions: tuple[Action, ...],
|
||||
*,
|
||||
cast_time: CastTimeResolver = _default_cast_time,
|
||||
free_draw: bool = False,
|
||||
) -> tuple[Action, ...]:
|
||||
"""Degrade a policy sequence to the legal PF1e action economy.
|
||||
|
||||
@@ -6964,7 +6988,8 @@ def _action_economy_filter(
|
||||
move action converts the standard slot (so (move, stand_up) and
|
||||
(move, move) are legal). The kept sequence is therefore the earliest
|
||||
order-stable legal prefix-subsequence; every skipped action is
|
||||
deterministic.
|
||||
deterministic. ``free_draw`` makes retrieve_weapon a free action (SRD
|
||||
"Move Actions", BAB +1 combined with a move — see _effective_slot).
|
||||
"""
|
||||
kept: list[Action] = []
|
||||
spent: dict[_ActionEconomySlot, bool] = {
|
||||
@@ -6975,7 +7000,7 @@ def _action_economy_filter(
|
||||
"free": False,
|
||||
}
|
||||
for action in actions:
|
||||
slot = _effective_slot(action, cast_time)
|
||||
slot = _effective_slot(action, cast_time, free_draw=free_draw)
|
||||
if slot == "free":
|
||||
kept.append(action)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user