✅ Insanity cannot trigger gear on enemy target
| Category | Interaction |
| Status | Passing |
| Test | tests/test_abilities_complex.py::TestOseInsanity::test_insanity_cannot_trigger_gear_on_enemy_target |
Tests interaction between Ose, Sabnock, Flauros.
Preconditions
-
P1 Main Phase, P1 has 6 AP, P2 has 6 AP
-
Lane 0: P1's Ose (#089) — READIED
-
Lane 0: P2's Sabnock (#003) — READIED
Action
-
Ose uses Insanity on P2's Sabnock
-
Insanity sets current_player = P2 for the bonus action
-
Gear check: current_player (P2) == Sabnock.owner (P2) → BLOCKED
-
Sabnock uses a non-gear ability instead (Pink Haze)
from engine.abilities import execute_ability
from engine.action_timing import can_perform_action, AbilityTiming, get_ability_timing
from engine.status_effects import get_stat_modifier, apply_status
from engine.rng import DeterministicRNG
import engine.abilities_actions
importlib.reload(engine.abilities_actions)
ose = make_demon("089", lane=0, owner=Side.PLAYER_1)
sabnock = make_demon("003", lane=0, owner=Side.PLAYER_2)
flauros = make_demon("013", lane=0, owner=Side.PLAYER_1)
state, placed = _make_state_with_demons(ose, sabnock, flauros, ap=6)
ose_p, sabnock_p, flauros_p = placed
rng = DeterministicRNG(42)
result = execute_ability(
state, ose_p, ability_idx=0,
targets=[sabnock_p],
rng=rng,
)
# current_player must be restored to P1
Expected Postconditions
-
current_player restored to P1
-
Gear actions were not available to Sabnock during the bonus action
Assertions
assert result.current_player == Side.PLAYER_1, (
f"current_player should be restored to P1 after Insanity resolves. "
f"Got {result.current_player}"
)
# Verify gear timing would block during the bonus action window:
# Simulate what the gear check sees when current_player == P2 (target's owner)
# and demon.owner == P2 (Sabnock)
from engine.constants import Phase
test_state = make_game_state(phase=Phase.MAIN, current_player=Side.PLAYER_2)
test_state.players[Side.PLAYER_2].ap = 6
test_demon = make_demon("003", lane=0, owner=Side.PLAYER_2)
test_state = place_demon(test_state, test_demon)
test_d = test_state.demons[0]
# A gear ability data dict
gear_ability = {"type": "Action", "timing": "gear", "ap_cost": 0,
"tap_required": False, "one_time_use": False}
from engine.action_timing import _can_perform_for_ability
ok, reason = _can_perform_for_ability(
test_state, test_d, gear_ability, AbilityTiming.GEAR
)
assert not ok, (
f"Gear should be blocked when current_player == demon.owner. "
f"Got ok={ok}, reason={reason}"
)
assert "gear" in reason.lower(), f"Reason should mention gear. Got: {reason}"