fix(rules): adjacent melee cover uses the SRD any-line rule (cover.md: 'any line from any corner of your square to the target's square goes through a wall') - the gate previously applied the ranged best-corner rule to distance-1 melee, systematically under-granting cover; non-adjacent melee (reach) keeps the ranged rule, bonus scoring aligned per branch, README 'pire coin' wording updated
This commit is contained in:
@@ -177,3 +177,31 @@ def test_melee_vs_large_target_picks_best_target_square() -> None:
|
||||
assert cover_bonus_cells(grid, attacker, frozenset({(0, 3)}), ranged=True) == 4
|
||||
assert cover_bonus_cells(grid, attacker, frozenset({(1, 3)}), ranged=False) == 0
|
||||
assert cover_bonus_cells(grid, attacker, frozenset({(1, 3)}), ranged=True) == 0
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# (g) adjacent melee uses the SRD any-line cover rule (cover.md), not the
|
||||
# ranged best-corner rule - engine AC effect
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_adjacent_melee_grazing_wall_grants_cover_to_ac() -> None:
|
||||
"""Wall (0,1) grazes one corner line of the adjacent pair (1,0)-(1,1).
|
||||
|
||||
SRD cover.md: "When making a melee attack against an adjacent target,
|
||||
your target has cover if any line from any corner of your square to
|
||||
the target's square goes through a wall." The ranged rule would find
|
||||
the attacker's top corner with all lines clear (no cover); the melee
|
||||
rule grants +4, and the engine's resolve_attack must apply it.
|
||||
"""
|
||||
grid = _grid((".#", ".."))
|
||||
attacker = make_combatant("gnoll", attack_bonus=4)
|
||||
target = make_combatant("warden", ac=13)
|
||||
states = [
|
||||
make_state(attacker, "players", (1, 0)),
|
||||
make_state(target, "monsters", (1, 1)),
|
||||
]
|
||||
engine = CombatEngine(ScriptedRng([12, 3, 12, 3]), grid, states)
|
||||
result = engine.resolve_attack(states[0], states[1], attacker.attacks[0])
|
||||
assert result.ac == 17 # 13 + 4 melee-adjacent cover
|
||||
assert result.hit is False # 12 + 4 = 16 < 17
|
||||
|
||||
Reference in New Issue
Block a user