74455c7b12
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 15s
CI / ui (pull_request) Successful in 45s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m10s
Add a per-game rule chosen on New Game for Russian variants (default off = the
single-word rule; on = standard Scrabble). Off, only the main word along the play
direction is validated and scored; perpendicular cross-words are ignored,
including in robot move generation. The rule rides every create and enqueue
request and joins the matchmaking key, so games and auto-match stay one uniform
path; "Russian-only" is a UI affordance (English always sends standard and shows
no toggle).
- Engine: consume scrabble-solver v1.1.0's PlayOptions{IgnoreCrossWords}, threaded
through engine.Options.MultipleWordsPerTurn -> playOpts() into validate, score
and generate.
- Backend: thread the flag through game CreateParams/Game + store (games column),
lobby InvitationSettings + invitation row, and the matchmaker queue key (variant
+ rule); persisted, so a rebuilt-from-journal game keeps it. Baseline migration
gains multiple_words_per_turn (DB not versioned); jet regenerated.
- Edge: multiple_words_per_turn added to the EnqueueRequest / CreateInvitationRequest
FlatBuffers tables (Go + TS regenerated) and threaded through the gateway.
- UI: a "Multiple words per turn" toggle on New Game, shown for Russian variants
only (auto-match and friend invite), default off; English silently sends standard.
- Tests: backend engine/matchmaker; UI unit (gating) + Playwright e2e (solver
corner-case + GCG fixtures ship in v1.1.0). Docs + PRERELEASE tracker updated.
144 lines
5.2 KiB
TypeScript
144 lines
5.2 KiB
TypeScript
// GatewayClient — the typed facade the screens call. Both the real Connect/
|
|
// FlatBuffers transport and the in-memory mock implement it. Domain failures (the
|
|
// gateway's result_code) and edge failures (Connect error codes) are normalised
|
|
// into a thrown GatewayError carrying a stable `code` the UI maps to an i18n
|
|
// message.
|
|
|
|
import type {
|
|
AccountRef,
|
|
ChatMessage,
|
|
EvalResult,
|
|
FriendCode,
|
|
GameList,
|
|
GameView,
|
|
GcgExport,
|
|
History,
|
|
HintResult,
|
|
Invitation,
|
|
InvitationSettings,
|
|
LinkResult,
|
|
MatchResult,
|
|
MoveResult,
|
|
Profile,
|
|
ProfileUpdate,
|
|
PushEvent,
|
|
Session,
|
|
StateView,
|
|
Stats,
|
|
Tile,
|
|
Variant,
|
|
WordCheckResult,
|
|
} from './model';
|
|
|
|
/** GatewayError carries a stable code (the gateway result_code, or an edge code). */
|
|
export class GatewayError extends Error {
|
|
readonly code: string;
|
|
constructor(code: string, message?: string) {
|
|
super(message ?? code);
|
|
this.name = 'GatewayError';
|
|
this.code = code;
|
|
}
|
|
}
|
|
|
|
/** A tile the player is submitting (rack/blank already resolved to a letter). */
|
|
export interface PlacedTile {
|
|
row: number;
|
|
col: number;
|
|
letter: string;
|
|
blank: boolean;
|
|
}
|
|
|
|
/** Unsubscribe handle for the live stream. */
|
|
export type Unsubscribe = () => void;
|
|
|
|
export interface GatewayClient {
|
|
// --- auth (unauthenticated) ---
|
|
authTelegram(initData: string): Promise<Session>;
|
|
authGuest(locale?: string): Promise<Session>;
|
|
authEmailRequest(email: string): Promise<void>;
|
|
authEmailLogin(email: string, code: string): Promise<Session>;
|
|
|
|
// --- profile / lists ---
|
|
profileGet(): Promise<Profile>;
|
|
gamesList(): Promise<GameList>;
|
|
|
|
// --- lobby ---
|
|
lobbyEnqueue(variant: Variant, multipleWords: boolean): Promise<MatchResult>;
|
|
lobbyPoll(): Promise<MatchResult>;
|
|
/** Leave the auto-match pool (idempotent); a cancelled quick-match must not stay queued. */
|
|
lobbyCancel(): Promise<void>;
|
|
|
|
// --- game ---
|
|
// The play loop exchanges alphabet indices, so submit/evaluate/exchange/
|
|
// check-word take the game's variant (to map letters<->indices via the cached alphabet
|
|
// table), and gameState's includeAlphabet asks the server to embed that table.
|
|
gameState(gameId: string, includeAlphabet: boolean): Promise<StateView>;
|
|
gameHistory(gameId: string): Promise<History>;
|
|
submitPlay(gameId: string, tiles: PlacedTile[], variant: Variant): Promise<MoveResult>;
|
|
pass(gameId: string): Promise<MoveResult>;
|
|
exchange(gameId: string, tiles: string[], variant: Variant): Promise<MoveResult>;
|
|
resign(gameId: string): Promise<MoveResult>;
|
|
hint(gameId: string): Promise<HintResult>;
|
|
evaluate(gameId: string, tiles: PlacedTile[], variant: Variant): Promise<EvalResult>;
|
|
checkWord(gameId: string, word: string, variant: Variant): Promise<WordCheckResult>;
|
|
complaint(gameId: string, word: string, note: string): Promise<void>;
|
|
/** Hide a finished game from the caller's own lobby list; per-account, irreversible. */
|
|
hideGame(gameId: string): Promise<void>;
|
|
|
|
// --- draft ---
|
|
/** The player's server-persisted client-side composition (rack order + board tiles), so a
|
|
* reload or a second device resumes the same arrangement. The JSON is opaque to the
|
|
* gateway; the client owns the {rack_order, board_tiles} shape. */
|
|
draftGet(gameId: string): Promise<string>;
|
|
draftSave(gameId: string, json: string): Promise<void>;
|
|
|
|
// --- chat ---
|
|
chatPost(gameId: string, body: string): Promise<ChatMessage>;
|
|
chatList(gameId: string): Promise<ChatMessage[]>;
|
|
nudge(gameId: string): Promise<ChatMessage>;
|
|
|
|
// --- friends ---
|
|
friendsList(): Promise<AccountRef[]>;
|
|
friendsIncoming(): Promise<AccountRef[]>;
|
|
/** Addressees the caller has already requested (pending or declined); cannot re-request. */
|
|
friendsOutgoing(): Promise<AccountRef[]>;
|
|
friendRequest(accountId: string): Promise<void>;
|
|
friendRespond(requesterId: string, accept: boolean): Promise<void>;
|
|
friendCancel(accountId: string): Promise<void>;
|
|
unfriend(accountId: string): Promise<void>;
|
|
friendCodeIssue(): Promise<FriendCode>;
|
|
friendCodeRedeem(code: string): Promise<AccountRef>;
|
|
|
|
// --- blocks ---
|
|
blocksList(): Promise<AccountRef[]>;
|
|
block(accountId: string): Promise<void>;
|
|
unblock(accountId: string): Promise<void>;
|
|
|
|
// --- invitations ---
|
|
invitationsList(): Promise<Invitation[]>;
|
|
invitationCreate(inviteeIds: string[], settings: InvitationSettings): Promise<Invitation>;
|
|
invitationAccept(invitationId: string): Promise<Invitation>;
|
|
invitationDecline(invitationId: string): Promise<Invitation>;
|
|
invitationCancel(invitationId: string): Promise<void>;
|
|
|
|
// --- profile / stats / history ---
|
|
profileUpdate(p: ProfileUpdate): Promise<Profile>;
|
|
statsGet(): Promise<Stats>;
|
|
exportGcg(gameId: string): Promise<GcgExport>;
|
|
|
|
// --- account linking & merge ---
|
|
linkEmailRequest(email: string): Promise<void>;
|
|
linkEmailConfirm(email: string, code: string): Promise<LinkResult>;
|
|
linkEmailMerge(email: string, code: string): Promise<LinkResult>;
|
|
linkTelegram(data: string): Promise<LinkResult>;
|
|
linkTelegramMerge(data: string): Promise<LinkResult>;
|
|
|
|
// --- live stream ---
|
|
subscribe(onEvent: (e: PushEvent) => void, onError?: (err: unknown) => void): Unsubscribe;
|
|
|
|
/** Set or clear the bearer token used for authenticated calls and the stream. */
|
|
setToken(token: string | null): void;
|
|
}
|
|
|
|
export type { GameView, Tile };
|