A room you can share by link, a code you can type, and a name to be called
Multiplayer setup moves out of a canvas modal and a prompt() dialog into one menu screen: your name, the two ways to host, and the friend's code. The socket opens from the menu and the game stays parked behind the overlay until the room fills — netHooks.paired takes the court one line before netStart writes to it — so the room code can carry a real SHARE button and a wrong code is a typo you fix rather than a CONNECTION LOST card over a match that never began. The name is the world board's name (stats.saveName), crosses on the existing look message, and the scoreboard finally names the person instead of CPU. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad258ace97
commit
425c18dcb6
7 files changed
+255
-75
No files matched your search
@@ -1645,6 +1645,19 @@ test('netplay: your look goes over the wire on pairing, and theirs comes back',
|
||||
state.selectKit(cfg.KITS[0].id); state.selectSkin(cfg.SKINS[0].id); // leave the table as found
|
||||
});
|
||||
|
||||
// THE NAME RIDES THE SAME MESSAGE — the lobby's one typed field, on the other phone's scoreboard.
|
||||
// It is a stranger's string landing in an 8-character slot, so it is normalised at the receiving
|
||||
// end (the same tidyName the world board and server.py's clean() agree on), never as sent.
|
||||
test('netplay: the friend names themselves, and the name lands tidy in the board\'s slot', () => {
|
||||
freshNet('A');
|
||||
const look = netTest.sent.find(m => m.t === 'look');
|
||||
assert.equal(look.n, statsMod.savedName(), 'this phone announces the name it remembers');
|
||||
netMsg({ t: 'look', k: 'red', s: 'pale', n: ' <b>bob</b>ranathan ' });
|
||||
assert.equal(G.net.look.name, 'BBOBBRAN', 'upper, stripped and cut to the eight-character slot');
|
||||
netMsg({ t: 'look', k: 'red', s: 'pale' }); // an older build sends no name at all
|
||||
assert.equal(G.net.look.name, 'FRIEND', '...and an unnamed opponent is FRIEND, never CPU');
|
||||
});
|
||||
|
||||
test('every kit and skin in the tables is a live, distinct pick', () => {
|
||||
for (const table of [cfg.KITS, cfg.SKINS]) {
|
||||
assert.equal(new Set(table.map(e => e.id)).size, table.length, 'ids are unique');
|
||||
|
||||
Reference in new issue
Block a user