Make all traps attackable and give them configurable HP - #32
Conversation
Traps had the full attack machinery wired (per-tile HP, takeDamage, target discovery) but TrapSpike and TrapBoulder overrode isAttackable to false, so only cannons and doors could ever be fought. Remove those overrides: every trap can now be attacked once the attacking seat has seen it trigger (the vision gate in Trap::isAttackable is kept, so hidden traps stay safe). Tile HP was a flat Building::DEFAULT_TILE_HP = 10 for everything. Add Trap::getTileHP() overridden per trap type from traps.cfg (BoulderHP, CannonHP, SpikeHP, WoodenDoorHP), read through a new getTrapConfigDoubleOrDefault so older config files without the new entries keep the old value of 10 instead of breaking. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
For destructible traps I am by whole heart .... For the destructible rooms I feel the opposite: they should only be reclaimable between players. That needs to be discussed, but no one says anything at our discord channel. |
|
Glad the traps part has your whole heart — that part is this PR, and it changes nothing about rooms. On the rooms side, one correction to the premise, because it matters for the discussion: "rooms only reclaimable" is not the current behaviour you'd be preserving — rooms are already destructible in the game today. Enemy fighters target visible enemy rooms and knock tiles out at a flat 10 HP each ( And the knob now covers your preference directly: I've just pushed a commit to #33 ( 🤖 Generated with Claude Code |
Issue tomluchowski#42 asks for explicit types instead of auto. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Proposal 1 of a set of PRs following the mechanics discussion in #23 (#23 (comment)) — this one covers the part Tom was certain about: "anyway Traps should be destructible".
It turns out the attack machinery for traps already exists end to end (per-tile HP,
Building::takeDamage, target discovery inGameMap::getVisibleForce, fight actions) — butTrapSpikeandTrapBoulderoverrideisAttackable()tofalse, so only cannons and wooden doors could actually be fought. This PR:Trap::isAttackableis deliberately kept: a trap that a player has never seen trigger stays invisible and unattackable for them, so hidden traps remain a real threat.Building::DEFAULT_TILE_HP = 10.0for every building in the game. Traps now readBoulderHP,CannonHP,SpikeHP,WoodenDoorHPfromtraps.cfgvia a newgetTrapConfigDoubleOrDefault(), which falls back to the old value of 10 when the entry is missing — older/custom config files keep working unchanged.The shipped values (Spike 10, Boulder 15, Cannon 20, WoodenDoor 25) are conservative first guesses to make sturdiness roughly track cost — obviously up for balance discussion, that's why they're config entries.
Not touched here: traps were already claimable tile-by-tile by enemy workers (
Trap::claimForSeatdestroys the danced tile), and that stays as it is.Validated: builds and the full test suite passes (including
ab-TestTraps) viactest.🤖 Generated with Claude Code