feat(social): per-game friend request to disguised robots + lobby/stats/tile cosmetics
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 54s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m25s
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 54s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m25s
Functional: the in-game add-friend handshake aimed at an auto-match opponent who is secretly a pooled robot now records the request per (game, seat) in a new robot_friend_requests table -- never against the shared robot account -- mirroring the robot_blocks pattern. The shared account stays out of friendships, the "requested" state is pinned to the seat (not leaked across the player's other games), the robot ignores it, and a background reaper drops the row 7 days after its game finishes. The outgoing-requests list carries these per-game rows so the seat control stays disabled across reloads. No withdraw UI, per owner decision. Cosmetics: - Lobby: an in-progress game tints the viewer's own score number green when leading or tied, red when trailing (reusing --ok/--danger); scores now render in seat-number order, matching the over-the-board scoreboard. - Stats: the per-variant best move is laid out on two lines -- the variant label, then the score (right-aligned in its column) and the word tiles (left-aligned) below it. - Dark theme: the played-tile background is a touch darker so a player-placed tile reads with more contrast (light theme unchanged). Docs (ARCHITECTURE, FUNCTIONAL + _ru mirror, backend README, UI_DESIGN) updated in the same change.
This commit is contained in:
+16
-8
@@ -932,6 +932,10 @@
|
||||
// re-send and disable the 🤝).
|
||||
let friends = $state(new Set<string>());
|
||||
let requested = $state(new Set<string>());
|
||||
// `requestedRobotSeats` are the seat indices of disguised-robot opponents already requested in
|
||||
// THIS game: a robot request is recorded per game+seat (never the shared robot account), so the
|
||||
// 🤝 disables for just this seat and never leaks across the requester's other games.
|
||||
let requestedRobotSeats = $state(new Set<number>());
|
||||
// `blocked` are the opponents the viewer has blocked: their 🤝 and ✖️ controls disappear and
|
||||
// their name is struck. Derived from the server so it is correct across reloads and live-updates
|
||||
// on a user_blocked / user_unblocked event. `blockedRobotSeats` are the seat indices of blocked
|
||||
@@ -952,7 +956,8 @@
|
||||
try {
|
||||
const [fl, out] = await Promise.all([gateway.friendsList(), gateway.friendsOutgoing()]);
|
||||
friends = new Set(fl.map((f) => f.accountId));
|
||||
requested = new Set(out.map((f) => f.accountId));
|
||||
requested = new Set(out.requests.map((f) => f.accountId));
|
||||
requestedRobotSeats = new Set(out.robots.filter((r) => r.gameId === id).map((r) => r.seat));
|
||||
} catch {
|
||||
/* best-effort */
|
||||
}
|
||||
@@ -981,14 +986,17 @@
|
||||
// caption update the instant the confirm fires) and roll back to the prior state if the command
|
||||
// fails to reach the server. The confirming user_blocked / user_added event then just reconciles
|
||||
// the same state in place (no flicker).
|
||||
async function addFriend(accountId: string) {
|
||||
const had = requested.has(accountId);
|
||||
requested = new Set([...requested, accountId]);
|
||||
async function addFriend(s: { accountId: string; seat: number }) {
|
||||
// Optimistically mark this seat requested (disables the 🤝 for both a human and a disguised
|
||||
// robot until the server confirms). The request carries the game id so a robot opponent is
|
||||
// recorded as a per-game request pinned to this seat, not against the shared robot account.
|
||||
const hadSeat = requestedRobotSeats.has(s.seat);
|
||||
requestedRobotSeats = new Set([...requestedRobotSeats, s.seat]);
|
||||
try {
|
||||
await gateway.friendRequest(accountId);
|
||||
await gateway.friendRequest(s.accountId, id);
|
||||
showToast(t('friends.requestSent'));
|
||||
} catch (e) {
|
||||
if (!had) requested = new Set([...requested].filter((id) => id !== accountId));
|
||||
if (!hadSeat) requestedRobotSeats = new Set([...requestedRobotSeats].filter((x) => x !== s.seat));
|
||||
handleError(e);
|
||||
}
|
||||
}
|
||||
@@ -1118,9 +1126,9 @@
|
||||
<span class="addfriend">
|
||||
<TapConfirm
|
||||
label={t('friends.addFromGame')}
|
||||
disabled={requested.has(s.accountId)}
|
||||
disabled={requested.has(s.accountId) || requestedRobotSeats.has(s.seat)}
|
||||
onConfirming={(v) => (addConfirm[s.seat] = v)}
|
||||
onconfirm={() => addFriend(s.accountId)}
|
||||
onconfirm={() => addFriend(s)}
|
||||
>
|
||||
<span class="fico">🤝</span>
|
||||
</TapConfirm>
|
||||
|
||||
Reference in New Issue
Block a user