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.
106 lines
3.6 KiB
Go
106 lines
3.6 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 Complaints = newComplaintsTable("backend", "complaints", "")
|
|
|
|
type complaintsTable struct {
|
|
postgres.Table
|
|
|
|
// Columns
|
|
ComplaintID postgres.ColumnString
|
|
ComplainantID postgres.ColumnString
|
|
GameID postgres.ColumnString
|
|
Variant postgres.ColumnString
|
|
DictVersion postgres.ColumnString
|
|
Word postgres.ColumnString
|
|
WasValid postgres.ColumnBool
|
|
Note postgres.ColumnString
|
|
Status postgres.ColumnString
|
|
CreatedAt postgres.ColumnTimestampz
|
|
|
|
AllColumns postgres.ColumnList
|
|
MutableColumns postgres.ColumnList
|
|
DefaultColumns postgres.ColumnList
|
|
}
|
|
|
|
type ComplaintsTable struct {
|
|
complaintsTable
|
|
|
|
EXCLUDED complaintsTable
|
|
}
|
|
|
|
// AS creates new ComplaintsTable with assigned alias
|
|
func (a ComplaintsTable) AS(alias string) *ComplaintsTable {
|
|
return newComplaintsTable(a.SchemaName(), a.TableName(), alias)
|
|
}
|
|
|
|
// Schema creates new ComplaintsTable with assigned schema name
|
|
func (a ComplaintsTable) FromSchema(schemaName string) *ComplaintsTable {
|
|
return newComplaintsTable(schemaName, a.TableName(), a.Alias())
|
|
}
|
|
|
|
// WithPrefix creates new ComplaintsTable with assigned table prefix
|
|
func (a ComplaintsTable) WithPrefix(prefix string) *ComplaintsTable {
|
|
return newComplaintsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
|
}
|
|
|
|
// WithSuffix creates new ComplaintsTable with assigned table suffix
|
|
func (a ComplaintsTable) WithSuffix(suffix string) *ComplaintsTable {
|
|
return newComplaintsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
|
}
|
|
|
|
func newComplaintsTable(schemaName, tableName, alias string) *ComplaintsTable {
|
|
return &ComplaintsTable{
|
|
complaintsTable: newComplaintsTableImpl(schemaName, tableName, alias),
|
|
EXCLUDED: newComplaintsTableImpl("", "excluded", ""),
|
|
}
|
|
}
|
|
|
|
func newComplaintsTableImpl(schemaName, tableName, alias string) complaintsTable {
|
|
var (
|
|
ComplaintIDColumn = postgres.StringColumn("complaint_id")
|
|
ComplainantIDColumn = postgres.StringColumn("complainant_id")
|
|
GameIDColumn = postgres.StringColumn("game_id")
|
|
VariantColumn = postgres.StringColumn("variant")
|
|
DictVersionColumn = postgres.StringColumn("dict_version")
|
|
WordColumn = postgres.StringColumn("word")
|
|
WasValidColumn = postgres.BoolColumn("was_valid")
|
|
NoteColumn = postgres.StringColumn("note")
|
|
StatusColumn = postgres.StringColumn("status")
|
|
CreatedAtColumn = postgres.TimestampzColumn("created_at")
|
|
allColumns = postgres.ColumnList{ComplaintIDColumn, ComplainantIDColumn, GameIDColumn, VariantColumn, DictVersionColumn, WordColumn, WasValidColumn, NoteColumn, StatusColumn, CreatedAtColumn}
|
|
mutableColumns = postgres.ColumnList{ComplainantIDColumn, GameIDColumn, VariantColumn, DictVersionColumn, WordColumn, WasValidColumn, NoteColumn, StatusColumn, CreatedAtColumn}
|
|
defaultColumns = postgres.ColumnList{NoteColumn, StatusColumn, CreatedAtColumn}
|
|
)
|
|
|
|
return complaintsTable{
|
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
|
|
|
//Columns
|
|
ComplaintID: ComplaintIDColumn,
|
|
ComplainantID: ComplainantIDColumn,
|
|
GameID: GameIDColumn,
|
|
Variant: VariantColumn,
|
|
DictVersion: DictVersionColumn,
|
|
Word: WordColumn,
|
|
WasValid: WasValidColumn,
|
|
Note: NoteColumn,
|
|
Status: StatusColumn,
|
|
CreatedAt: CreatedAtColumn,
|
|
|
|
AllColumns: allColumns,
|
|
MutableColumns: mutableColumns,
|
|
DefaultColumns: defaultColumns,
|
|
}
|
|
}
|