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
|
|
@ -8,7 +8,7 @@
|
|||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="Netwall">
|
||||
<meta name="description" content="Netwall: build firewalls, stretch the route, protect the server. A maze tower defence game with two-player co-op.">
|
||||
<meta name="description" content="Netwall: build firewalls, stretch the route, protect the server. A maze tower defence game with two-player co-op and attack-vs-defend versus.">
|
||||
<title>Netwall</title>
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<link rel="icon" href="icons/icon.svg" type="image/svg+xml">
|
||||
|
|
@ -36,6 +36,23 @@
|
|||
<symbol id="i-trash" viewBox="0 0 24 24"><path d="M5 7h14M10 7V4.5h4V7M7 7l1 12.5h8L17 7M10.5 11v5M13.5 11v5" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"/></symbol>
|
||||
<symbol id="i-users" viewBox="0 0 24 24"><circle cx="9" cy="8.5" r="3.3" fill="currentColor"/><path d="M2.5 19.5c0-3.6 2.9-5.6 6.5-5.6s6.5 2 6.5 5.6z" fill="currentColor"/><circle cx="17" cy="9.5" r="2.5" fill="currentColor" opacity=".7"/><path d="M16.5 14.2c3 0 5 1.6 5 4.6h-4.2" fill="currentColor" opacity=".7"/></symbol>
|
||||
<symbol id="i-target" viewBox="0 0 24 24"><circle cx="12" cy="12" r="7.5" fill="none" stroke="currentColor" stroke-width="2"/><circle cx="12" cy="12" r="2.2" fill="currentColor"/><path d="M12 2.5v4M12 17.5v4M2.5 12h4M17.5 12h4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
|
||||
<symbol id="i-clock" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5" fill="none" stroke="currentColor" stroke-width="2.2"/><path d="M12 7v5.2l3.4 2" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></symbol>
|
||||
<symbol id="i-launch" viewBox="0 0 24 24"><path d="M6 18L18 6M9 6h9v9" fill="none" stroke="currentColor" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round"/></symbol>
|
||||
<symbol id="i-ab-emp" viewBox="0 0 24 24"><path d="M13.5 3L5.5 13.5h5.5L10 21l8.5-11h-5.5z" fill="currentColor"/></symbol>
|
||||
<symbol id="i-ab-decoy" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="none" stroke="currentColor" stroke-width="2" stroke-dasharray="3.2 3"/><circle cx="12" cy="12" r="3" fill="currentColor"/></symbol>
|
||||
<symbol id="i-ab-surge" viewBox="0 0 24 24"><path d="M5 18l7-7 7 7M5 11.5l7-7 7 7" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/></symbol>
|
||||
<symbol id="i-ab-ddos" viewBox="0 0 24 24"><path d="M4.5 15a7.5 7.5 0 0115 0M8 15a4 4 0 018 0" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/><circle cx="12" cy="17.5" r="1.8" fill="currentColor"/><path d="M4 21h16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="1 3.2"/></symbol>
|
||||
<symbol id="i-tl-scan" viewBox="0 0 24 24"><circle cx="10.5" cy="10.5" r="5.8" fill="none" stroke="currentColor" stroke-width="2.2"/><path d="M15 15l5 5" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"/></symbol>
|
||||
<symbol id="i-tl-patch" viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="4" fill="none" stroke="currentColor" stroke-width="2.2"/><path d="M12 8v8M8 12h8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></symbol>
|
||||
<symbol id="i-tl-repair" viewBox="0 0 24 24"><path d="M4.5 19.5L13 11" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><circle cx="16.2" cy="7.8" r="4" fill="none" stroke="currentColor" stroke-width="2.2"/></symbol>
|
||||
<symbol id="i-tl-quarantine" viewBox="0 0 24 24"><rect x="5.5" y="11" width="13" height="9.5" rx="2.2" fill="currentColor"/><path d="M8.5 11V8a3.5 3.5 0 017 0v3" fill="none" stroke="currentColor" stroke-width="2.2"/></symbol>
|
||||
<symbol id="i-te-armor" viewBox="0 0 24 24"><path d="M12 3l7 3v5.5c0 4.6-3 7.6-7 9.5-4-1.9-7-4.9-7-9.5V6z" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linejoin="round"/></symbol>
|
||||
<symbol id="i-te-speed" viewBox="0 0 24 24"><path d="M5.5 6l6 6-6 6M12.5 6l6 6-6 6" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/></symbol>
|
||||
<symbol id="i-te-health" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14" stroke="currentColor" stroke-width="3.4" stroke-linecap="round"/></symbol>
|
||||
<symbol id="i-te-regen" viewBox="0 0 24 24"><path d="M19 12a7 7 0 11-2.2-5.1M19 4.5v4.3h-4.3" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></symbol>
|
||||
<symbol id="i-te-shield" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="none" stroke="currentColor" stroke-width="2.2"/><path d="M7.8 12a4.2 4.2 0 014.2-4.2" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/></symbol>
|
||||
<symbol id="i-te-stealth" viewBox="0 0 24 24"><path d="M2.5 12s3.6-6 9.5-6 9.5 6 9.5 6-3.6 6-9.5 6-9.5-6-9.5-6z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><circle cx="12" cy="12" r="2.6" fill="currentColor"/><path d="M4.5 20L19.5 4" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></symbol>
|
||||
<symbol id="i-te-crypt" viewBox="0 0 24 24"><circle cx="8" cy="12" r="3.6" fill="none" stroke="currentColor" stroke-width="2.2"/><path d="M11.6 12H21M17.5 12v3.2M20.5 12v2.2" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/></symbol>
|
||||
<symbol id="i-fs" viewBox="0 0 24 24"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></symbol>
|
||||
</defs>
|
||||
</svg>
|
||||
|
|
@ -44,9 +61,10 @@
|
|||
|
||||
<header id="topbar">
|
||||
<button id="btnMenu" class="icon" aria-label="Menu"><svg class="ic"><use href="#i-menu"/></svg></button>
|
||||
<div class="stat vs-only" id="statTime" title="Round time left"><svg class="ic"><use href="#i-clock"/></svg><b id="vTime">0:00</b></div>
|
||||
<div class="stat" id="statWave" title="Wave"><span class="lbl">WAVE</span><b id="vWave">0</b><small id="vWaveMax"></small></div>
|
||||
<div class="stat" id="statLives" title="Server integrity"><svg class="ic"><use href="#i-heart"/></svg><b id="vLives">20</b></div>
|
||||
<div class="stat" id="statGold" title="Credits"><svg class="ic"><use href="#i-coin"/></svg><b id="vGold">0</b></div>
|
||||
<div class="stat" id="statGold" title="Credits"><svg class="ic"><use href="#i-coin"/></svg><b id="vGold">0</b><small id="vIncome" class="vs-only"></small></div>
|
||||
<button id="netChip" class="chip" type="button" hidden title="Co-op room: tap to invite your partner" aria-label="Co-op room. Tap to invite your partner"><svg class="ic"><use href="#i-users"/></svg><span id="netRoom"></span><span id="netPing"></span><svg class="ic share"><use href="#i-share"/></svg></button>
|
||||
<div class="spacer"></div>
|
||||
<button id="btnWave" class="primary" aria-label="Start next wave"><svg class="ic"><use href="#i-play"/></svg><span id="btnWaveText">Wave 1</span></button>
|
||||
|
|
@ -61,6 +79,10 @@
|
|||
<div id="hint" class="hint" hidden></div>
|
||||
<div id="banner" class="banner" aria-live="polite"></div>
|
||||
<button id="pausedTag" class="paused-tag" type="button" hidden><svg class="ic"><use href="#i-play"/></svg><span>PAUSED<small>tap to resume</small></span></button>
|
||||
<div id="vsHud" class="vshud" hidden></div>
|
||||
<div id="vsNote" class="hint info" hidden></div>
|
||||
<div id="vsFx" class="vsfx" aria-live="polite"></div>
|
||||
<div id="vsCount" class="vscount" hidden></div>
|
||||
<div id="toasts" aria-live="polite"></div>
|
||||
<button id="btnFit" class="icon floating" aria-label="Reset zoom" hidden><svg class="ic"><use href="#i-fit"/></svg></button>
|
||||
<div id="confirm" class="confirm" hidden>
|
||||
|
|
@ -79,6 +101,8 @@
|
|||
|
||||
<aside id="side">
|
||||
<section id="palette" aria-label="Build"></section>
|
||||
<section id="vsbar" class="vsbar" aria-label="Versus controls" hidden></section>
|
||||
<section id="vstech" class="vstech" aria-label="Tech upgrades" hidden></section>
|
||||
<section id="info" aria-live="polite"></section>
|
||||
<section id="nextwave"></section>
|
||||
<section id="players" hidden></section>
|
||||
|
|
@ -98,9 +122,10 @@
|
|||
<div id="diffPick" class="seg" role="radiogroup" aria-label="Difficulty"></div><!-- Easy / Normal / Hard, built by main.js from TD.DIFFICULTIES -->
|
||||
<p id="diffNote" class="diffnote"></p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row modes">
|
||||
<button id="btnSolo" class="primary big"><svg class="ic"><use href="#i-play"/></svg>Play solo</button>
|
||||
<button id="btnCoop" class="big"><svg class="ic"><use href="#i-users"/></svg>Co-op online</button>
|
||||
<button id="btnVersus" class="big"><svg class="ic"><use href="#i-ab-emp"/></svg>Versus</button>
|
||||
</div>
|
||||
<button id="btnResume" class="big resume" hidden></button>
|
||||
<div class="row small">
|
||||
|
|
@ -144,6 +169,77 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===== versus setup (solo against the computer, or create / join an online room) ===== -->
|
||||
<div id="vsSetup" class="overlay" hidden role="dialog" aria-modal="true" aria-labelledby="vsSetupTitle">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 id="vsSetupTitle">Versus</h2>
|
||||
<p class="muted lead">One of you builds the maze, the other sends the packets. Two rounds, the roles swap. Whoever breaks the server fastest wins.</p>
|
||||
<p class="muted small" id="vsMapName"></p>
|
||||
<div class="vsfield"><span class="flabel">You play</span><div id="vsRolePick" class="seg" role="radiogroup" aria-label="Your role"></div></div>
|
||||
<div class="vsfield"><span class="flabel">Round length</span><div id="vsLimitPick" class="seg" role="radiogroup" aria-label="Round length"></div></div>
|
||||
<div class="vsfield"><span class="flabel">Computer skill</span><div id="vsSkillPick" class="seg" role="radiogroup" aria-label="Computer skill"></div></div>
|
||||
<div class="vsonline">
|
||||
<h3>Online</h3>
|
||||
<label class="field"><span>Your name</span><input id="vsName" maxlength="16" autocomplete="nickname" autocapitalize="words" spellcheck="false" placeholder="Player"></label>
|
||||
<div class="joinrow">
|
||||
<input id="vsCode" class="code" maxlength="4" autocomplete="off" autocapitalize="characters" spellcheck="false" inputmode="text" placeholder="ABCD" aria-label="Room code">
|
||||
<button id="btnVsJoin" class="big">Join</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-foot">
|
||||
<p id="vsMsg" class="msg" role="status"></p>
|
||||
<div class="row">
|
||||
<button id="btnVsComputer" class="primary big">Play the computer</button>
|
||||
<button id="btnVsCreate" class="big"><svg class="ic"><use href="#i-users"/></svg>Create room</button>
|
||||
</div>
|
||||
<div class="row small"><button id="btnVsBack" class="link">← Back</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===== versus room: roles, ready, computer seat, start ===== -->
|
||||
<div id="vsRoom" class="overlay" hidden role="dialog" aria-modal="true" aria-labelledby="vsRoomTitle">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 id="vsRoomTitle">Versus room</h2>
|
||||
<div class="vsroomhead"><span class="rc" id="vsRoomCode"></span><span id="vsRoomLimit" class="muted small"></span><button id="btnVsInvite" type="button" class="link">Invite</button></div>
|
||||
<div id="vsSeats" class="vsseats"></div>
|
||||
<div class="vsfield"><span class="flabel">Your role</span><div id="vsRoomRole" class="seg" role="radiogroup" aria-label="Your role"></div></div>
|
||||
<div class="vsfield" id="vsOppField"><span class="flabel">Opponent</span><div id="vsRoomOpp" class="seg" role="radiogroup" aria-label="Opponent"></div></div>
|
||||
<p id="vsRoomNote" class="muted small"></p>
|
||||
</div>
|
||||
<div class="card-foot">
|
||||
<p id="vsRoomMsg" class="msg" role="status"></p>
|
||||
<div class="row">
|
||||
<button id="btnVsReady" class="big">I'm ready</button>
|
||||
<button id="btnVsStart" class="primary big">Start match</button>
|
||||
</div>
|
||||
<div class="row small"><button id="btnVsLeave" class="link">Leave room</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===== versus: round over / match over ===== -->
|
||||
<div id="vsEnd" class="overlay" hidden role="dialog" aria-modal="true" aria-labelledby="vsEndTitle" aria-describedby="vsEndText">
|
||||
<div class="card wide">
|
||||
<div class="card-body">
|
||||
<h2 id="vsEndTitle"></h2>
|
||||
<p id="vsEndText" class="muted"></p>
|
||||
<div id="vsEndRounds" class="vsrounds"></div>
|
||||
</div>
|
||||
<div class="card-foot">
|
||||
<p id="vsEndWait" class="msg" role="status" hidden></p>
|
||||
<div class="row">
|
||||
<button id="btnVsNext" class="primary big">Next round</button>
|
||||
<button id="btnVsRematch" class="primary big">Rematch</button>
|
||||
<button id="btnVsEndMenu" class="big">Menu</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===== help ===== -->
|
||||
<div id="help" class="overlay" hidden role="dialog" aria-modal="true" aria-labelledby="helpTitle">
|
||||
<div class="card wide">
|
||||
|
|
@ -156,6 +252,7 @@
|
|||
<li><b>Credits.</b> Earned from kills and every cleared wave. Upgrade turrets up to level 3. Sell for 70% back (walls refund in full).</li>
|
||||
<li><b>Controls.</b> <span class="kbd-only">Click to build, drag to paint walls, right-click to cancel. Keys <span id="helpKeys">1–6</span> pick a tower, Space starts a wave, U upgrades, X sells, T changes targeting, P pauses, F changes speed, M mutes, wheel zooms.</span>
|
||||
<span class="touch-only">Tap a tower type, then tap the map to preview; nudge the cell with the arrows and tap ✓ to build. Walls paint as you drag. Pinch to zoom, two fingers to pan, long-press to ping your partner.</span></li>
|
||||
<li><b>Versus.</b> One player <b>defends</b> (builds the maze and turrets as usual, with counter-tools: Scan, Patch, Repair, Quarantine) and the other <b>attacks</b>: spend credits on packets (tap a unit to buy; <i>Stage</i> pays now and holds them for one <b>Launch</b>), buy tech upgrades, and sabotage the defence (EMP a turret, Decoy, Surge, DDoS). Tap a gateway to choose where packets enter. A round ends when the server falls or the clock runs out; then the roles swap. Whoever breaks the server fastest wins the match. No pause, no speed control. Play a friend online or the computer.</li>
|
||||
<li><b>Co-op.</b> Both players share everything and can build, sell and upgrade at the same time. You see each other's cursors; long-press / Alt-click pings the map.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
@ -186,9 +283,11 @@
|
|||
</div>
|
||||
|
||||
<script src="js/sim.js"></script>
|
||||
<script src="js/bot.js"></script>
|
||||
<script src="js/audio.js"></script>
|
||||
<script src="js/controllers.js"></script>
|
||||
<script src="js/render.js"></script>
|
||||
<script src="js/versus.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue