Fix: placed Firewalls can be selected and sold again

renderInfo assumed every tower has three levels; walls have one, so selecting a
wall threw. Use each tower's own level count and add an e2e scenario that
selects, upgrades, retargets and sells every kind of tower.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
Claude 2026-10-10 15:26:49 +00:00
parent 72c49eee1f
commit 10bd6f1b04
4 changed files with 57 additions and 13 deletions

View file

@ -16,13 +16,9 @@ Development was paused on purpose before the fix stage. This file is the entry p
`npm test` = 80 passing (20 sim + 59 server + 1 balance-table shape test). Verified from a fresh `git clone`.
## KNOWN BUG in the pushed build (fix first, it is two lines)
## Fixed since this was written
**Selecting a placed Firewall throws a TypeError, so walls cannot be sold** (finding `visual-1`, confirmed).
Cause: `renderInfo()` in `public/js/main.js` assumes every tower has 3 levels (`tower.level < 3`), but a wall has one
level, so `statsFor(type, i + 1)` and `def.levels[tower.level].cost` read `levels[1]`, which is `undefined`. Use
`tower.level < def.levels.length` in both places (and for the `up` button / `updateInfoDynamic`). Add an e2e assertion:
build a wall, tap it, tap Sell, check the credits.
* 2026-10-10: selecting a placed Firewall no longer throws (walls can be sold again; e2e scenario `06-select-sell`).
## Suggested order of work