towerdef/docs/VERSUS.md
Claude dad0382e10 docs: versus mode design and roadmap
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
2026-10-10 15:48:10 +00:00

5.4 KiB

Versus mode: attack vs defend ("play as the Internet")

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 opponent for either side so it can be played alone.

Match structure

  • A match is two rounds with the roles swapped (host picks who starts as what; or random).
  • A round ends when the server falls (attacker wins, the time it took is recorded) or when the round timer runs out (defender wins; default 12 minutes, host can pick 8 / 12 / 16).
  • Match result compares each player's attacking performance: faster fall wins; if neither felled the server, the one who took off more integrity wins; otherwise draw. Show both rounds side by side on the result screen.
  • No pause, no speed control in versus (both would be exploitable). Disconnect: the round freezes up to the 60 s grace; on expiry the other player wins the round.

Attacker economy ("bandwidth")

Rule Starting value (to be tuned with the bot)
Start credits 150
Base income 4 credits/s, rising slowly (+0.02/s per second of the round)
Lifetime bonus every living attacker unit earns cost x 0.004 credits per second alive, capped at 50% of its cost in total
Leak bonus a unit that reaches the server pays back its full cost (and damages integrity)
Unit shop every enemy kind has a buyCost (pinger 10, worm 14, spam pack 20, ghost 40, trojan 60, healer 70, rootkit 400, ...)
Caps at most 250 units alive, 200 staged (performance)

Save up and launch. Units can be bought instantly (spawn) or staged (stage): the price is paid now, the units wait in a convoy and are released together by launch (optionally split over gateways, as a 3 s burst). The defender sees the size of the staged convoy but not its composition. Presets for one tap: Rush (20 pings), Swarm (60 spam), Siege (4 trojans + a healer), Air raid (10 ghosts), Boss (rootkit).

Tech upgrades (permanent for the round, apply to units spawned afterwards): Armor (+1 per level, 5 levels), Speed (+8%), Health (+15%), Regeneration (+1% hp/s), Shield (absorbs damage), Stealth (towers cannot acquire a unit for its first second on the map, 3 levels), Encryption (resists slows). Costs double per level.

Sabotage abilities (credits + cooldown): EMP disables one turret for 6 s; Decoy a harmless packet every turret prioritises for 5 s; Surge all units +40% speed for 6 s; DDoS all turrets fire 40% slower for 4 s (long cooldown).

Defender economy and counter-tools

  • Start credits 250, kill rewards (scaled by unit cost), plus a small trickle (2/s), so the defender can adapt before the first rush.
  • Builds, upgrades and sells as today (walls still can never seal the route).
  • Counter-tools: Scan (reveals stealth for a few seconds and clears EMP on turrets in an area), Patch (instantly re-enable an EMPed turret), Repair (restore 3 integrity, long cooldown, costs credits), Quarantine (freeze every unit on the board for 2 s, very long cooldown).

More suggestions (not decided yet)

  • Gateway choice per spawn on multi-gateway maps; attacker sees a faint heat-map of where the defender's fire is strongest.
  • A short ready/countdown before each round so both players are present; a rematch button that swaps roles.
  • Spectators (third connection, read-only) later.
  • Handicap sliders in the lobby (attacker income, defender start credits) for mixed-skill pairs.
  • Per-map, per-difficulty leaderboard of attack times once the server leaderboard exists.
  • The bot defender is the maze builder from tools/bot.js moved into shared code; the bot attacker is a budgeted spender that reacts to the tower mix (flyers if there is no anti-air, armoured trojans against filters, saves for a convoy).

Implementation plan

  1. Sim (public/js/sim.js, pure, with unit tests): mode: 'versus', attacker state (credits, income, tech levels, staged convoy, cooldowns), commands spawn, stage, launch, tech, ability, defender tools, round timer and result, role checks (a command carries the issuer's role; the sim refuses cross-role commands). Add buyCost to the enemy table. No automatic waves.
  2. Bots shared by browser and server (public/js/bot.js), driven only through the public sim API.
  3. Server (server/room.js, protocol): room option mode: 'coop' | 'versus', role assignment, ready/countdown, rounds and swap, per-role command whitelist, attacker data in snapshots, match result message, bot seat. Update docs/PROTOCOL.md and tests.
  4. Client: lobby (mode, role, limit, bot), role-aware HUD: attacker gets the unit shop (the palette becomes the shop), tech panel, abilities, convoy and Launch, income readout, round timer; defender keeps the build palette plus counter-tools. Phone layout first (the action bar pattern), same canvas renderer.
  5. Balance with bot-versus-bot matches over the maps (like tools/bot.js does for solo): neither side should win more than about 60% of rounds on any map.
  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.