Skip to content

Give room tiles configurable hit points per room type - #33

Open
Upabjojr wants to merge 3 commits into
tomluchowski:shaders-improvementfrom
Upabjojr:split/room-hp
Open

Give room tiles configurable hit points per room type#33
Upabjojr wants to merge 3 commits into
tomluchowski:shaders-improvementfrom
Upabjojr:split/room-hp

Conversation

@Upabjojr

@Upabjojr Upabjojr commented Aug 6, 2026

Copy link
Copy Markdown

Proposal 2 of the set following the mechanics discussion in #23 (#23 (comment)) — the "rooms destructible" side of the "claimable or destructible" question.

Rooms are in fact already destructible today: enemy fighters (not workers) target visible enemy rooms, damage them tile by tile, and a tile at 0 HP is removed from the room — with the recently merged room splitting (#23) even cutting a room in two. But every tile of every room has a flat Building::DEFAULT_TILE_HP = 10.0, which a mid-level creature removes in a couple of swings, and there is no way to tune it. As a mechanic it exists but has no knobs.

This PR gives it knobs: Room::getTileHP() reads <RoomName>HP from rooms.cfg (e.g. DormitoryHP, TreasuryHP, DungeonTempleHP), falling back to the old 10 when an entry is missing, so older config files keep working. Shipped defaults make rooms meaningfully sturdier than a creature (30–50 HP per tile, 100 for the dungeon temple) — first-guess numbers, meant to be argued about in the config file rather than in code.

Notes for the design discussion:

  • A destroyed room tile stays claimed by its old owner (Building::removeCoveredTile does not unclaim), so the owner can rebuild on it cheaply, while the attacker would still have to dance the ground afterwards. Destruction is therefore already less "permanent" than it sounds — the owner loses the building and half the gold, not the territory.
  • Repair (Room::repairRoom) is currently only ever called by the AI keeper; human players just re-buy tiles. Making repair a player action could be a follow-up if the destructible route is chosen.

This proposal is independent of the others in the set: it can be merged alone, together with the traps one (#32), or alongside the claimable-rooms prototype — the mechanics compose (some rooms could be claimable and all of them destructible, DK2-style).

Validated: builds and the full test suite passes via ctest.

🤖 Generated with Claude Code

Enemy fighters already attack and destroy rooms tile by tile, but every
tile of every room had the same flat Building::DEFAULT_TILE_HP = 10 --
a couple of swings from a mid-level creature -- and there was no way to
tune it. Room::getTileHP() now reads <RoomName>HP from rooms.cfg (e.g.
DormitoryHP, DungeonTempleHP) through a new
getRoomConfigDoubleOrDefault that falls back to the old value of 10
when the entry is missing, so older config files keep working.

The shipped values make rooms meaningfully sturdier than a creature and
the dungeon temple the hardest to bring down; they are meant to be
argued about in the config file, not in code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Following the review discussion: with hit points configurable per room
type, a keeper who prefers rooms to change hands only through claiming
can now say so directly - configure a room's HP to 0 and it cannot be
attacked at all. Room::isAttackable refuses targets on such rooms, and
Room::takeDamage shields them from stray damage that bypasses target
selection (rolling boulders, area effects). Internally the tiles keep a
positive HP value, since zero HP means "tile destroyed" everywhere
else.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Upabjojr

Copy link
Copy Markdown
Author

Pushed 19ae3288 following the discussion on #32: <RoomName>HP = 0 now means the room is indestructibleRoom::isAttackable refuses targets on it, and a Room::takeDamage override shields it from stray damage that bypasses target selection (rolling boulders, area effects). Internally its tiles keep positive HP, since zero HP means "tile destroyed" everywhere else. Documented in rooms.cfg.

So both camps of the "claimable vs destructible" question are now a config choice per room type: 0 = reclaim-only, any positive value = attackable with that many hit points per tile.

🤖 Generated with Claude Code

Issue tomluchowski#42 asks for explicit types instead of auto.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant