751e74b14f
internal/game drives the engine over a single match and owns everything the
engine does not: event-sourced persistence (a games row + an append-only decoded
move journal, with the live engine.Game kept warm in a cache and rebuilt by
replay on a miss), the play/pass/exchange/resign transitions with
validate-at-submit scoring, an unlimited score/legality preview, the hint
(per-game allowance + profile wallet), the word-check tool with complaint
capture, per-player game state, history and GCG export (Poslfit dialect), and a
background turn-timeout sweeper that auto-resigns overdue turns honouring each
player's daily away window. Like Stages 1-2 it is a service/store layer with no
HTTP; the gateway surface lands in Stage 6.
Engine: additive decoded domain API (Direction, SubmitPlay/SubmitExchange/
EvaluatePlay/HintView/Hand, MoveRecord.{Dir,MainRow,MainCol}, Registry.Lookup,
ParseVariant) so internal/game never imports scrabble-solver; and a Resign fix
so the resigner keeps their score yet never wins (the other player wins a
two-player game). Timeout reuses Resign.
Persistence: migration 00002 adds games, game_players, game_moves, complaints,
account_stats and extends accounts with away_start/away_end/hint_balance; go-jet
regenerated. account gained SpendHint. Config adds BACKEND_DICT_DIR (required),
BACKEND_DICT_VERSION, BACKEND_GAME_TIMEOUT_SWEEP_INTERVAL, BACKEND_GAME_CACHE_TTL;
main loads the registry at boot (hard dependency) and starts the sweeper.
Tests: engine resign + decoded-API tests; game unit tests (GCG, away-window
boundaries, hint budget, cache, keyed mutex, payload); inttest integration
(lifecycle, replay equivalence, timeout sweep with away grace, resign stats,
hint policy, word-check/complaint, per-game-lock). Docs (PLAN, ARCHITECTURE,
FUNCTIONAL +_ru, TESTING, README) updated.
94 lines
2.9 KiB
Go
94 lines
2.9 KiB
Go
//
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
//
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
// and will be lost if the code is regenerated
|
|
//
|
|
|
|
package table
|
|
|
|
import (
|
|
"github.com/go-jet/jet/v2/postgres"
|
|
)
|
|
|
|
var GamePlayers = newGamePlayersTable("backend", "game_players", "")
|
|
|
|
type gamePlayersTable struct {
|
|
postgres.Table
|
|
|
|
// Columns
|
|
GameID postgres.ColumnString
|
|
Seat postgres.ColumnInteger
|
|
AccountID postgres.ColumnString
|
|
Score postgres.ColumnInteger
|
|
HintsUsed postgres.ColumnInteger
|
|
IsWinner postgres.ColumnBool
|
|
|
|
AllColumns postgres.ColumnList
|
|
MutableColumns postgres.ColumnList
|
|
DefaultColumns postgres.ColumnList
|
|
}
|
|
|
|
type GamePlayersTable struct {
|
|
gamePlayersTable
|
|
|
|
EXCLUDED gamePlayersTable
|
|
}
|
|
|
|
// AS creates new GamePlayersTable with assigned alias
|
|
func (a GamePlayersTable) AS(alias string) *GamePlayersTable {
|
|
return newGamePlayersTable(a.SchemaName(), a.TableName(), alias)
|
|
}
|
|
|
|
// Schema creates new GamePlayersTable with assigned schema name
|
|
func (a GamePlayersTable) FromSchema(schemaName string) *GamePlayersTable {
|
|
return newGamePlayersTable(schemaName, a.TableName(), a.Alias())
|
|
}
|
|
|
|
// WithPrefix creates new GamePlayersTable with assigned table prefix
|
|
func (a GamePlayersTable) WithPrefix(prefix string) *GamePlayersTable {
|
|
return newGamePlayersTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
|
}
|
|
|
|
// WithSuffix creates new GamePlayersTable with assigned table suffix
|
|
func (a GamePlayersTable) WithSuffix(suffix string) *GamePlayersTable {
|
|
return newGamePlayersTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
|
}
|
|
|
|
func newGamePlayersTable(schemaName, tableName, alias string) *GamePlayersTable {
|
|
return &GamePlayersTable{
|
|
gamePlayersTable: newGamePlayersTableImpl(schemaName, tableName, alias),
|
|
EXCLUDED: newGamePlayersTableImpl("", "excluded", ""),
|
|
}
|
|
}
|
|
|
|
func newGamePlayersTableImpl(schemaName, tableName, alias string) gamePlayersTable {
|
|
var (
|
|
GameIDColumn = postgres.StringColumn("game_id")
|
|
SeatColumn = postgres.IntegerColumn("seat")
|
|
AccountIDColumn = postgres.StringColumn("account_id")
|
|
ScoreColumn = postgres.IntegerColumn("score")
|
|
HintsUsedColumn = postgres.IntegerColumn("hints_used")
|
|
IsWinnerColumn = postgres.BoolColumn("is_winner")
|
|
allColumns = postgres.ColumnList{GameIDColumn, SeatColumn, AccountIDColumn, ScoreColumn, HintsUsedColumn, IsWinnerColumn}
|
|
mutableColumns = postgres.ColumnList{AccountIDColumn, ScoreColumn, HintsUsedColumn, IsWinnerColumn}
|
|
defaultColumns = postgres.ColumnList{ScoreColumn, HintsUsedColumn, IsWinnerColumn}
|
|
)
|
|
|
|
return gamePlayersTable{
|
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
|
|
|
//Columns
|
|
GameID: GameIDColumn,
|
|
Seat: SeatColumn,
|
|
AccountID: AccountIDColumn,
|
|
Score: ScoreColumn,
|
|
HintsUsed: HintsUsedColumn,
|
|
IsWinner: IsWinnerColumn,
|
|
|
|
AllColumns: allColumns,
|
|
MutableColumns: mutableColumns,
|
|
DefaultColumns: defaultColumns,
|
|
}
|
|
}
|