feat: "multiple words per turn" rule for Russian games
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
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.
This commit is contained in:
@@ -49,6 +49,8 @@ type InvitationSettings struct {
|
||||
HintsAllowed bool
|
||||
HintsPerPlayer int
|
||||
DropoutTiles engine.DropoutTiles
|
||||
// MultipleWordsPerTurn true selects standard Scrabble; false the single-word rule.
|
||||
MultipleWordsPerTurn bool
|
||||
}
|
||||
|
||||
// Invitee is one invited player's seat and response.
|
||||
@@ -214,14 +216,15 @@ func (svc *InvitationService) CreateInvitation(ctx context.Context, inviterID uu
|
||||
return Invitation{}, fmt.Errorf("lobby: new invitation id: %w", err)
|
||||
}
|
||||
ins := invitationInsert{
|
||||
id: id,
|
||||
inviterID: inviterID,
|
||||
variant: settings.Variant.String(),
|
||||
turnTimeoutSecs: int(settings.TurnTimeout / time.Second),
|
||||
hintsAllowed: settings.HintsAllowed,
|
||||
hintsPerPlayer: settings.HintsPerPlayer,
|
||||
dropoutTiles: settings.DropoutTiles.String(),
|
||||
expiresAt: svc.now().Add(invitationTTL),
|
||||
id: id,
|
||||
inviterID: inviterID,
|
||||
variant: settings.Variant.String(),
|
||||
turnTimeoutSecs: int(settings.TurnTimeout / time.Second),
|
||||
hintsAllowed: settings.HintsAllowed,
|
||||
hintsPerPlayer: settings.HintsPerPlayer,
|
||||
dropoutTiles: settings.DropoutTiles.String(),
|
||||
multipleWordsPerTurn: settings.MultipleWordsPerTurn,
|
||||
expiresAt: svc.now().Add(invitationTTL),
|
||||
}
|
||||
if err := svc.store.insertInvitation(ctx, ins, inviteeIDs); err != nil {
|
||||
return Invitation{}, err
|
||||
@@ -265,12 +268,13 @@ func (svc *InvitationService) startGame(ctx context.Context, invitationID uuid.U
|
||||
seats[iv.Seat] = iv.AccountID
|
||||
}
|
||||
g, err := svc.games.Create(ctx, game.CreateParams{
|
||||
Variant: inv.Settings.Variant,
|
||||
Seats: seats,
|
||||
TurnTimeout: inv.Settings.TurnTimeout,
|
||||
HintsAllowed: inv.Settings.HintsAllowed,
|
||||
HintsPerPlayer: inv.Settings.HintsPerPlayer,
|
||||
DropoutTiles: inv.Settings.DropoutTiles,
|
||||
Variant: inv.Settings.Variant,
|
||||
Seats: seats,
|
||||
TurnTimeout: inv.Settings.TurnTimeout,
|
||||
HintsAllowed: inv.Settings.HintsAllowed,
|
||||
HintsPerPlayer: inv.Settings.HintsPerPlayer,
|
||||
DropoutTiles: inv.Settings.DropoutTiles,
|
||||
MultipleWordsPerTurn: inv.Settings.MultipleWordsPerTurn,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -322,6 +326,8 @@ type invitationInsert struct {
|
||||
hintsPerPlayer int
|
||||
dropoutTiles string
|
||||
expiresAt time.Time
|
||||
// multipleWordsPerTurn false selects the single-word rule.
|
||||
multipleWordsPerTurn bool
|
||||
}
|
||||
|
||||
// respondResult reports the state after an invitee response.
|
||||
@@ -335,8 +341,8 @@ func (s *Store) insertInvitation(ctx context.Context, ins invitationInsert, invi
|
||||
ii := table.GameInvitations.INSERT(
|
||||
table.GameInvitations.InvitationID, table.GameInvitations.InviterID, table.GameInvitations.Variant,
|
||||
table.GameInvitations.TurnTimeoutSecs, table.GameInvitations.HintsAllowed, table.GameInvitations.HintsPerPlayer,
|
||||
table.GameInvitations.DropoutTiles, table.GameInvitations.ExpiresAt,
|
||||
).VALUES(ins.id, ins.inviterID, ins.variant, ins.turnTimeoutSecs, ins.hintsAllowed, ins.hintsPerPlayer, ins.dropoutTiles, ins.expiresAt)
|
||||
table.GameInvitations.DropoutTiles, table.GameInvitations.MultipleWordsPerTurn, table.GameInvitations.ExpiresAt,
|
||||
).VALUES(ins.id, ins.inviterID, ins.variant, ins.turnTimeoutSecs, ins.hintsAllowed, ins.hintsPerPlayer, ins.dropoutTiles, ins.multipleWordsPerTurn, ins.expiresAt)
|
||||
if _, err := ii.ExecContext(ctx, tx); err != nil {
|
||||
return fmt.Errorf("insert invitation: %w", err)
|
||||
}
|
||||
@@ -377,11 +383,12 @@ func (s *Store) loadInvitation(ctx context.Context, id uuid.UUID) (Invitation, e
|
||||
ID: row.InvitationID,
|
||||
InviterID: row.InviterID,
|
||||
Settings: InvitationSettings{
|
||||
Variant: variant,
|
||||
TurnTimeout: time.Duration(row.TurnTimeoutSecs) * time.Second,
|
||||
HintsAllowed: row.HintsAllowed,
|
||||
HintsPerPlayer: int(row.HintsPerPlayer),
|
||||
DropoutTiles: dropout,
|
||||
Variant: variant,
|
||||
TurnTimeout: time.Duration(row.TurnTimeoutSecs) * time.Second,
|
||||
HintsAllowed: row.HintsAllowed,
|
||||
HintsPerPlayer: int(row.HintsPerPlayer),
|
||||
DropoutTiles: dropout,
|
||||
MultipleWordsPerTurn: row.MultipleWordsPerTurn,
|
||||
},
|
||||
Status: row.Status,
|
||||
GameID: row.GameID,
|
||||
|
||||
Reference in New Issue
Block a user