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.
103 lines
3.5 KiB
Go
103 lines
3.5 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 GameMoves = newGameMovesTable("backend", "game_moves", "")
|
|
|
|
type gameMovesTable struct {
|
|
postgres.Table
|
|
|
|
// Columns
|
|
GameID postgres.ColumnString
|
|
Seq postgres.ColumnInteger
|
|
Seat postgres.ColumnInteger
|
|
Action postgres.ColumnString
|
|
Score postgres.ColumnInteger
|
|
RunningTotal postgres.ColumnInteger
|
|
ExchangedCount postgres.ColumnInteger
|
|
Payload postgres.ColumnString
|
|
CreatedAt postgres.ColumnTimestampz
|
|
|
|
AllColumns postgres.ColumnList
|
|
MutableColumns postgres.ColumnList
|
|
DefaultColumns postgres.ColumnList
|
|
}
|
|
|
|
type GameMovesTable struct {
|
|
gameMovesTable
|
|
|
|
EXCLUDED gameMovesTable
|
|
}
|
|
|
|
// AS creates new GameMovesTable with assigned alias
|
|
func (a GameMovesTable) AS(alias string) *GameMovesTable {
|
|
return newGameMovesTable(a.SchemaName(), a.TableName(), alias)
|
|
}
|
|
|
|
// Schema creates new GameMovesTable with assigned schema name
|
|
func (a GameMovesTable) FromSchema(schemaName string) *GameMovesTable {
|
|
return newGameMovesTable(schemaName, a.TableName(), a.Alias())
|
|
}
|
|
|
|
// WithPrefix creates new GameMovesTable with assigned table prefix
|
|
func (a GameMovesTable) WithPrefix(prefix string) *GameMovesTable {
|
|
return newGameMovesTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
|
}
|
|
|
|
// WithSuffix creates new GameMovesTable with assigned table suffix
|
|
func (a GameMovesTable) WithSuffix(suffix string) *GameMovesTable {
|
|
return newGameMovesTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
|
}
|
|
|
|
func newGameMovesTable(schemaName, tableName, alias string) *GameMovesTable {
|
|
return &GameMovesTable{
|
|
gameMovesTable: newGameMovesTableImpl(schemaName, tableName, alias),
|
|
EXCLUDED: newGameMovesTableImpl("", "excluded", ""),
|
|
}
|
|
}
|
|
|
|
func newGameMovesTableImpl(schemaName, tableName, alias string) gameMovesTable {
|
|
var (
|
|
GameIDColumn = postgres.StringColumn("game_id")
|
|
SeqColumn = postgres.IntegerColumn("seq")
|
|
SeatColumn = postgres.IntegerColumn("seat")
|
|
ActionColumn = postgres.StringColumn("action")
|
|
ScoreColumn = postgres.IntegerColumn("score")
|
|
RunningTotalColumn = postgres.IntegerColumn("running_total")
|
|
ExchangedCountColumn = postgres.IntegerColumn("exchanged_count")
|
|
PayloadColumn = postgres.StringColumn("payload")
|
|
CreatedAtColumn = postgres.TimestampzColumn("created_at")
|
|
allColumns = postgres.ColumnList{GameIDColumn, SeqColumn, SeatColumn, ActionColumn, ScoreColumn, RunningTotalColumn, ExchangedCountColumn, PayloadColumn, CreatedAtColumn}
|
|
mutableColumns = postgres.ColumnList{SeatColumn, ActionColumn, ScoreColumn, RunningTotalColumn, ExchangedCountColumn, PayloadColumn, CreatedAtColumn}
|
|
defaultColumns = postgres.ColumnList{ScoreColumn, RunningTotalColumn, ExchangedCountColumn, PayloadColumn, CreatedAtColumn}
|
|
)
|
|
|
|
return gameMovesTable{
|
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
|
|
|
//Columns
|
|
GameID: GameIDColumn,
|
|
Seq: SeqColumn,
|
|
Seat: SeatColumn,
|
|
Action: ActionColumn,
|
|
Score: ScoreColumn,
|
|
RunningTotal: RunningTotalColumn,
|
|
ExchangedCount: ExchangedCountColumn,
|
|
Payload: PayloadColumn,
|
|
CreatedAt: CreatedAtColumn,
|
|
|
|
AllColumns: allColumns,
|
|
MutableColumns: mutableColumns,
|
|
DefaultColumns: defaultColumns,
|
|
}
|
|
}
|