feat(ui): per-kind active-game limit lock on the New Game screen
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 12s
CI / integration (pull_request) Successful in 28s
CI / ui (pull_request) Successful in 1m11s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m46s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 12s
CI / integration (pull_request) Successful in 28s
CI / ui (pull_request) Successful in 1m11s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m46s
Carry the caller's per-tier active-game caps and each game's kind on the wire (Profile.game_limits + GameView.kind, additive FBS + gateway transcode + client codec, committed regen). The New Game screen counts the player's active games per kind from the lobby and locks a capped start: an outline button with a lock that opens a funnel modal instead of a game -- a sign-in prompt for a guest, a "finish a current game first" notice for a signed-in account (native Telegram popup, in-app modal elsewhere). The lock lifts via the existing profile refetch after a guest->durable upgrade. Remove the lobby's old at_game_limit New-Game tab disable + notice: the flag (now the random-kind cap) conflicted with the per-kind lock -- it hid the screen where the lock lives and wrongly blocked an unfulfilled kind. The New Game tab is always enabled; the per-kind start lock is the only gate. The at_game_limit wire field stays (unused by the client) for a later cleanup. Tests: client lock logic + codec kind/game_limits roundtrip + gateway transcode encode + native popup builders (unit); a mock e2e for the lock badge and the modal.
This commit is contained in:
@@ -15,6 +15,7 @@ import type {
|
||||
RobotFriendRequestEntry,
|
||||
Banner,
|
||||
AdsConfig,
|
||||
GameLimits,
|
||||
BannerCampaign,
|
||||
BestMove,
|
||||
BestMoveTile,
|
||||
@@ -314,6 +315,7 @@ function decodeGameView(g: fb.GameView): GameView {
|
||||
vsAi: g.vsAi(),
|
||||
unreadChat: g.unreadChat(),
|
||||
unreadMessages: g.unreadMessages(),
|
||||
kind: g.kind(),
|
||||
seats,
|
||||
};
|
||||
}
|
||||
@@ -467,9 +469,18 @@ export function decodeProfile(buf: Uint8Array): Profile {
|
||||
telegramLinked: p.telegramLinked(),
|
||||
vkLinked: p.vkLinked(),
|
||||
dictVersions: decodeDictVersions(p),
|
||||
gameLimits: decodeGameLimits(p),
|
||||
};
|
||||
}
|
||||
|
||||
// decodeGameLimits projects the caller's tier active-game caps (per kind, -1 = unlimited), or
|
||||
// undefined when absent (an old backend); the New-Game screen then applies no lock.
|
||||
function decodeGameLimits(p: fb.Profile): GameLimits | undefined {
|
||||
const g = p.gameLimits();
|
||||
if (!g) return undefined;
|
||||
return { vsAi: g.vsAi(), random: g.random(), friends: g.friends() };
|
||||
}
|
||||
|
||||
// decodeDictVersions reads the profile's per-variant current dictionary versions into a
|
||||
// variant-keyed map, so the offline preloader can look up the version for each enabled
|
||||
// variant. An entry with an unknown variant or empty version is skipped.
|
||||
@@ -1137,6 +1148,7 @@ function emptyGame(): GameView {
|
||||
vsAi: false,
|
||||
unreadChat: false,
|
||||
unreadMessages: false,
|
||||
kind: 0,
|
||||
seats: [],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user