The toss travels: the receiver watches the serve coming
One event on the toss, replayed as a real toss over O — update() already poses the server off the phase and drops an uncaught ball back to pretoss by plain physics, so the wind-up, the cancel and the re-toss all carry for free. The strike's shot event overwrites whatever drifted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f302354bb2
commit
8face714a6
4 files changed
+36
-4
No files matched your search
@@ -1239,6 +1239,24 @@ test('netplay: an outbound ball is picture — this phone never judges its own s
|
||||
assert.ok(!netTest.sent.some(m => m.t === 'pt'), 'applying a verdict does not echo one back');
|
||||
});
|
||||
|
||||
test('netplay: the toss travels — the receiver watches the serve coming', () => {
|
||||
freshNet('A'); // this phone serves: its toss must go over the wire
|
||||
keyPressed('Space');
|
||||
assert.equal(G.phase, 'toss', 'the tap tossed');
|
||||
assert.ok(netTest.sent.some(m => m.t === 'toss'), 'the toss is an event');
|
||||
freshNet('B'); // ...and on the receiving phone
|
||||
netMsg({ t: 'toss' });
|
||||
assert.equal(G.phase, 'toss', 'their toss is a live toss here');
|
||||
assert.ok(ball.active && ball.lastHit === 'O' && ball.vy > 0, 'a real ball rising over O');
|
||||
assert.ok(ball.z < COURT.netZ, 'on the far half');
|
||||
for (let i = 0; i < 300 && G.phase === 'toss'; i++) update(DT); // nobody strikes it
|
||||
assert.equal(G.phase, 'pretoss', 'an uncaught remote toss falls back by plain physics');
|
||||
netMsg({ t: 'toss' }); // the re-toss, then the strike over it
|
||||
netMsg({ t: 'shot', x: 1.3, y: 2.6, z: 24.3, vx: -2, vy: 2, vz: -30, g: 12, pow: 0.8, serve: true });
|
||||
assert.equal(G.phase, 'rally', 'the strike lands cleanly over the replayed toss');
|
||||
assert.ok(ball.vz > 0, 'and the serve is inbound');
|
||||
});
|
||||
|
||||
test('netplay: a serve fault is the receiver\'s call, and re-arms the server\'s second serve', () => {
|
||||
freshNet('B'); // they serve — long, out of the box
|
||||
netMsg({ t: 'shot', x: 0.5, y: 2.6, z: 24.3, vx: 0, vy: 1, vz: -35, g: 9.2, pow: 1, serve: true });
|
||||
|
||||
Reference in new issue
Block a user