fix(rules): stop steal from taking held weapons
PF1e (APG Steal): "Items held in the hands (such as wielded weapons or wands) also cannot be taken with the steal maneuver—you must use the disarm combat maneuver instead." The model carries no non-held items, so a successful steal now takes nothing and logs "nothing stealable — wielded weapons require disarm". README updated; the retrieve_weapon tests keep locking the restoration mechanism directly. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -355,17 +355,20 @@ def test_dirty_trick_fails_on_natural_1() -> None:
|
||||
assert engine._transcript[-1].endswith("-> FAILED")
|
||||
|
||||
|
||||
def test_steal_takes_melee_weapon() -> None:
|
||||
def test_steal_refuses_wielded_weapon() -> None:
|
||||
# APG Steal: "Items held in the hands (such as wielded weapons or wands)
|
||||
# also cannot be taken with the steal maneuver—you must use the disarm
|
||||
# combat maneuver instead." The target's sword is wielded: the success
|
||||
# steals nothing.
|
||||
a_spec = make_combatant("a", attack_bonus=2)
|
||||
b_spec = make_combatant("b")
|
||||
a = make_state(a_spec, "players", (1, 1))
|
||||
b = make_state(b_spec, "monsters", (1, 2))
|
||||
hp_before = b.hp
|
||||
engine = make_engine([1, 12], [a, b])
|
||||
engine._execute_maneuver(a, b, "steal")
|
||||
assert "b-w" in b.weapon_stolen
|
||||
assert engine.weapon_for(b, a) is None
|
||||
assert b.hp == hp_before
|
||||
assert not b.weapon_stolen
|
||||
assert engine.weapon_for(b, a) is not None # the sword stays usable
|
||||
assert "nothing stealable — wielded weapons require disarm" in engine._transcript[-1]
|
||||
|
||||
|
||||
def test_steal_nothing_to_steal() -> None:
|
||||
@@ -376,7 +379,7 @@ def test_steal_nothing_to_steal() -> None:
|
||||
engine = make_engine([12], [a, b])
|
||||
engine._execute_maneuver(a, b, "steal")
|
||||
assert not b.weapon_stolen
|
||||
assert "nothing to steal" in engine._transcript[-1]
|
||||
assert "nothing stealable" in engine._transcript[-1]
|
||||
|
||||
|
||||
def test_reposition_moves_to_first_free_neighbor() -> None:
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
L7 of the ``llm-policy-contract`` plan: ``Action`` gains a
|
||||
``retrieve_weapon`` kind and a ``weapon_id`` field so a policy can restore a
|
||||
weapon that a steal maneuver took from its owner. The weapon is removed from
|
||||
``state.weapon_stolen`` and becomes usable again via ``usable_attacks()``.
|
||||
weapon rendered unusable in ``state.weapon_stolen``. The weapon is removed
|
||||
from ``state.weapon_stolen`` and becomes usable again via ``usable_attacks()``.
|
||||
(The steal maneuver no longer fills this set: APG Steal forbids taking wielded
|
||||
weapons.)
|
||||
|
||||
No default policy emits ``retrieve_weapon``; it is only accepted by
|
||||
``_execute`` (usage via custom policy / LLM).
|
||||
@@ -77,9 +79,11 @@ def test_retrieve_restores_stolen_weapon() -> None:
|
||||
b_spec = make_combatant("b")
|
||||
a = make_state(a_spec, "players", (1, 1))
|
||||
b = make_state(b_spec, "monsters", (1, 2))
|
||||
engine = make_engine([1, 12], [a, b])
|
||||
engine._execute(a, Action(kind="maneuver", target_id="b", maneuver="steal"))
|
||||
assert "b-w" in b.weapon_stolen
|
||||
# The steal maneuver no longer takes wielded weapons (APG Steal), so the
|
||||
# stolen state is set directly — retrieve_weapon is the mechanism under
|
||||
# test here.
|
||||
b.weapon_stolen.add("b-w")
|
||||
engine = make_engine([], [a, b])
|
||||
assert "b-w" not in _weapon_ids(b)
|
||||
engine._execute(b, Action(kind="retrieve_weapon", weapon_id="b-w"))
|
||||
assert not b.weapon_stolen
|
||||
@@ -114,17 +118,21 @@ def test_retrieve_unknown_id_logs_nothing_to_retrieve() -> None:
|
||||
assert b.weapon_stolen == {"b-w"}
|
||||
|
||||
|
||||
# --- Test 4: real steal then retrieve restores the weapon --------------------
|
||||
# --- Test 4: steal leaves wielded weapons; retrieve restores a stolen id -----
|
||||
|
||||
def test_steal_then_retrieve_restores_weapon() -> None:
|
||||
# APG Steal: a wielded weapon cannot be taken — the maneuver provokes,
|
||||
# succeeds, and steals nothing; the owner keeps swinging. A weapon that IS
|
||||
# stolen (model state set directly) is restored by retrieve_weapon.
|
||||
a_spec = make_combatant("a", attack_bonus=2)
|
||||
b_spec = make_combatant("b")
|
||||
a = make_state(a_spec, "players", (1, 1))
|
||||
b = make_state(b_spec, "monsters", (1, 2))
|
||||
engine = make_engine([1, 12], [a, b])
|
||||
engine._execute(a, Action(kind="maneuver", target_id="b", maneuver="steal"))
|
||||
assert "b-w" in b.weapon_stolen
|
||||
assert engine.weapon_for(b, a) is None
|
||||
assert not b.weapon_stolen
|
||||
assert engine.weapon_for(b, a) is not None
|
||||
b.weapon_stolen.add("b-w")
|
||||
engine._execute(b, Action(kind="retrieve_weapon", weapon_id="b-w"))
|
||||
assert not b.weapon_stolen
|
||||
assert engine.weapon_for(b, a) is not None
|
||||
|
||||
Reference in New Issue
Block a user