Repository navigation
Tanks: every two-phone shot on both phones, live opponent aim, link chip as in Battleship (#861) - #868
Conversation
…tleship (#861) A phone counts a shot only once it lands (G.M0), so while a shot flew or a turn waited in the inbox, the phone looked a shot behind. A sync in that window (every reconnect sends one) was read as "you are behind": the newer match was adopted, the flying shot vanished and a queued one was dropped, so the shot showed on one phone only, in either direction. Such a sync now waits until nothing flies or waits, and is read against the landed match. The host answered a digest mismatch with its match from before the shot, so a drifted guest answered back with its own and stayed off; the host now sends the match after the shot. A shot that arrives while the phone looks away flies again on return instead of landing unseen. The host/join choice and its sentence stayed on screen all match; as in Battleship they show only until the phones are linked, then one small link chip. Before a role is picked the status no longer says "Rival is aiming" on both seats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QY4t6rHpbsoE5aS15nw6Z7
Diff reviewRoot cause (1), with evidence. Each phone counts a shot in
Second bug found on the way. On a digest mismatch the host called Why this fix. A sync that arrives while something flies or waits is held in (2) Link bar. No shared link-bar piece exists in the core: Reversi, Battleship and Tanks each build theirs with Tested
Not tested
|
The owner asked to see the other player aim on two phones. While a player sets the angle and power, the page sends them (at most every 66 ms, the last position always) and the other phone draws that barrel and label with the existing aim drawing. The aim is kept apart from the match, tied to the match and shot number, and dropped when the shot starts; the turn message alone decides where a shot goes, so a late or lost aim changes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QY4t6rHpbsoE5aS15nw6Z7
Diff review: the live aim view (second commit)What. The owner asked on #861 to see the other player aim. Tanks now streams the aim while a player sets it, and the other phone draws it with the same barrel, line and "angle° · power" label used for its own aim. Why this shape.
Tested
Not tested
|






Closes #861
What changed
onSyncno longer acts while a shot is flying or a received turn is still queued; the sync is held (G.held) and read bysettle()once the shot has landed and the queue is empty.pump()is restructured to callsettle()when it has nothing left to play.G.M0holds the shot that just landed, not before.Connected, orConnection lost…mid-match), placed before the gear. Before a role is picked, the status line is empty and the seats read Player 1 / Player 2, instead of "Rival is aiming" on both.aimNow()returns their aim on their turn).aimOut()sends{t:'aim', g, n, angle, power}fromdraw()only when the value changed, at most once every 66 ms (~15/s), with a trailing send so the last position always arrives. The receiver keeps it inpeerAim, outside the match: it is never written intoG.M, never in a digest or sync, accepted only for the current matchgand shot numbernon the other's turn, and dropped when the shot starts. Theturnmessage stays the only authority on where a shot goes, so a late or lost aim message changes nothing.games.json:updatedfor tanks set to 2026-11-12.tools/tests/tanks-link-shots.js.No new strings. No change to the core
makeLink.Proof
The new group run on its own against
origin/main(old page) and against this branch:On
origin/main(old page), exit 1:On this branch, exit 0:
Playwright, two linked contexts at 390×800, fa/en × light/dark: on every combination the guest's canvas changed 9 times while the host turned its barrel with the keys, and the host's canvas changed 7 times while the guest aimed. Against the old page the same run gave 1 distinct frame on each phone, which is the control. Screenshots are in the review comment.
Browser fuzz (two Playwright pages joined by a fake ChoganNearby plugin relayed through Node, ordered per direction with 20–400 ms delays, the link dropped and restored ~25 times and a page hidden ~17 times per match, 20 shots each): old page 2 of 2 matches lost shots (
adopt killed a flight, in the first match shot 13 never drew on the host and shot 14 never drew on the guest); this branch 0 of 2.🤖 Generated with Claude Code
https://claude.ai/code/session_01QY4t6rHpbsoE5aS15nw6Z7