Versus mode: attack vs defend (sim, bots, server, client)
One player defends, the other plays the Internet: earns credits over time and spends them on packets, upgrades and sabotage. Two rounds with swapped roles, timed (the faster fall wins). Built end to end, NOT yet QA'd or balanced. Sim (public/js/sim.js, TD.VS table): attacker economy (income, lifetime bonus, leak payback), spawn / stage / launch convoys, 7 tech tracks, abilities (EMP, decoy, surge, DDoS), defender tools (scan, patch, repair, quarantine), role-checked commands, round result, role-private state. Co-op/solo unchanged (24 scripted games replay identically). Bots (public/js/bot.js, tools/versus.js): defender (maze + turrets) and attacker (budgeted spender reading the tower mix); headless bot-vs-bot runner. Server (server/versus.js, protocol doc): versus rooms with lobby / countdown / playing / roundover / matchover, role stamping, cross-role refusal, role-private priv messages at 4 Hz, computer seat, freeze/forfeit rules, no pause/speed. Client (public/js/versus.js): setup dialog (role, length, vs computer or online), countdown, defender tools row, attacker unit shop with convoy + launch, tech and abilities, gateway choice, round/match screens, sounds, phone-first dock rows. Status and next steps (balance: the attacker currently wins ~100% of bot rounds; QA with two browsers; layout matrix rerun) are in docs/NEXT.md and docs/VERSUS.md. The full planned workflow incl. balance/QA prompts is in docs/workflows/versus-full.js. 253 unit tests pass; one smoke e2e run; no other e2e per the user's request. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
parent
b4ae6cb57d
commit
2098d59c1f
23 changed files with 6166 additions and 90 deletions
|
|
@ -1,5 +1,10 @@
|
|||
# Versus mode: attack vs defend ("play as the Internet")
|
||||
|
||||
> **Status 2026-10-11:** implemented end to end (sim + bots, server + protocol, client UI) but **not QA'd and not balanced**. With the shipped numbers
|
||||
> the attacker bot wins ~100% of rounds on every map; the cheap 3-credit swarm units (botnet, spam) are the dominant lever (botnet 8 and spam 6
|
||||
> flips it to ~0%; botnet 6 / spam 4 / worm 8 lands near 75%). The remaining planned steps (balance pass with `tools/versus.js`, independent QA with
|
||||
> two real browsers) are in `docs/workflows/versus-full.js` (the BALANCE and QA prompts at its end).
|
||||
|
||||
Requested 2026-10-10. One player **defends** (builds the maze and turrets, as today); the other **attacks** (earns credits over
|
||||
time, spends them on spawning packets, upgrades and sabotage). Same board, same rules, one authoritative simulation per room.
|
||||
Decisions made with the user: timed rounds then swap roles; attacker abilities *and* defender counter-tools; a computer
|
||||
|
|
@ -72,3 +77,31 @@ prioritises for 5 s; *Surge* all units +40% speed for 6 s; *DDoS* all turrets fi
|
|||
6. **e2e**: two browsers play a round each way; one bot match.
|
||||
|
||||
Depends on the content wave (new enemy kinds become shop items) and on the difficulty/economy constants, so it comes after them.
|
||||
|
||||
## Client as built (2026-10-11)
|
||||
|
||||
All of it lives in `public/js/versus.js` (`NW.Versus`, created by `main.js`; with no versus game running it does nothing, so solo and co-op are untouched) plus the
|
||||
`#vsSetup`, `#vsRoom` and `#vsEnd` dialogs in `index.html`, a block at the end of `style.css`, versus cues in `render.js` and the new sounds in `audio.js`.
|
||||
|
||||
* **Entering.** Menu -> *Versus* -> setup dialog: your role (Attack / Defend / Random), round length (8 / 12 / 16 min, from `TD.VS.LIMITS`), computer skill (Easy 0.35 /
|
||||
Normal 0.7 / Hard 1). *Play the computer* starts a `LocalController` match (no server, no lobby: it starts in its 3 s countdown). *Create room* / *Join* (code) go to the
|
||||
server; an invite link (`?room=`) still opens the co-op lobby dialog and works for a versus room too (the room says what it is).
|
||||
* **Room (online lobby).** Seats with role badge and ready flag, your role (Attack / Defend / Random), host-only *Opponent: A friend / Computer*, host *Start match* (disabled with the
|
||||
reason until the opponent is online and ready), guest *I'm ready*. Then a countdown card on the stage ("Round 1 of 2: YOU ATTACK"), round over (`#vsEnd`, both rounds side by side,
|
||||
*Next round*), match over (the server's verdict from `vs.winner` / `vs.forfeit`, never recomputed; *Rematch (roles swap)*). A frozen room (opponent offline) shows a PAUSED card.
|
||||
* **Defender HUD.** Today's tower palette, plus a tools row under it: Scan (tap, then tap the map; radius ring follows the pointer), Patch (re-enables the selected disabled tower, else
|
||||
the one with most EMP left), Repair, Quarantine (second tap to confirm, like every action of 150+ credits). Each has a cooldown ring + seconds and greys out when it cannot be afforded.
|
||||
* **Attacker HUD.** The palette becomes the unit shop (every `TD.ENEMY_ORDER` kind with `buyCost`, price shown for the chosen quantity; a tap buys; fewer is bought when credits fall short),
|
||||
then a row `[x1|x5|x10] [Send|Stage] [Any gate|Gate n] [LAUNCH n + convoy composition]`, the four abilities with cooldown rings (EMP: tap it, then a tower; or select a tower and use the
|
||||
button in its action bar), and the tech row (7 upgrades, level pips, price doubling per level). Credits (smoothly run forward from the 4 Hz `priv` data) and income are in the top bar,
|
||||
units alive and the defender's credits in a pill on the stage. Tapping a gateway (or the gate button) chooses where packets enter; units appearing at a gateway pulse it for both sides.
|
||||
Keys: 1-9 buy that unit, Space launches. Optimistic local bookkeeping (credits, cooldown start) is overwritten by the next `priv`.
|
||||
* **Layout.** Stacked layouts: the dock (convoy row + abilities / tools) is pinned to the bottom of the side panel and the board gets less height (`V.minSide`); the tech row scrolls like the
|
||||
shop. Short landscape: the shop and tech are scrolling grids in the 200 px column, the abilities keep four columns as icon + cost.
|
||||
* **Rendering.** EMP'd towers are dimmed with hazard stripes, sparks and a draining arc; armed EMP outlines every target; decoys are dashed-ringed and half transparent (from the `decoy`
|
||||
event on the wire, `m.decoy` locally); the attacker sees its own stealth (cloak shimmer for the first seconds) and shield (ring) because the wire carries neither (inferred from its tech
|
||||
levels when the unit first appears, exact in a local match); Surge (orange edge), DDoS (violet scan lines), Quarantine (icy tint) and Scan zones are drawn for both sides. The defender
|
||||
deliberately sees no stealth or shield cue (it does not know the attacker's tech).
|
||||
* **Known limits.** A local match cannot be paused (versus has no pause; `LocalController.ctl` ignores it), so opening the menu in a computer match leaves the round running behind it.
|
||||
Presets (Rush, Swarm, ...) from the design are not in the UI yet; the x1/x5/x10 selector covers most of it.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue