Documentation
¶
Overview ¶
Package store provides persistent storage for saved games.
Index ¶
- func DefaultDBPath() string
- type GameRecord
- type GameStatus
- type Store
- func (s *Store) Close() error
- func (s *Store) CreateGame(rec *GameRecord) error
- func (s *Store) GetGameByName(name string) (*GameRecord, error)
- func (s *Store) ListAllGames() ([]GameRecord, error)
- func (s *Store) ListGames() ([]GameRecord, error)
- func (s *Store) NameExists(name string) (bool, error)
- func (s *Store) UpdateSaveState(id int64, saveState string) error
- func (s *Store) UpdateStatus(id int64, status GameStatus) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GameRecord ¶
type GameStatus ¶
type GameStatus string
const ( StatusNew GameStatus = "new" StatusInProgress GameStatus = "in_progress" StatusCompleted GameStatus = "completed" StatusAbandoned GameStatus = "abandoned" )
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func Open ¶
Open creates the directory if needed, opens the database, creates the table, and enables WAL mode.
func (*Store) CreateGame ¶
func (s *Store) CreateGame(rec *GameRecord) error
CreateGame inserts a new game record and sets rec.ID.
func (*Store) GetGameByName ¶
func (s *Store) GetGameByName(name string) (*GameRecord, error)
GetGameByName looks up a single non-abandoned game by its unique name. Returns nil, nil if no matching game is found.
func (*Store) ListAllGames ¶
func (s *Store) ListAllGames() ([]GameRecord, error)
ListAllGames returns all games (including abandoned) ordered by most recently updated.
func (*Store) ListGames ¶
func (s *Store) ListGames() ([]GameRecord, error)
ListGames returns all non-abandoned games ordered by most recently updated.
func (*Store) NameExists ¶
NameExists checks whether a game with the given name already exists.
func (*Store) UpdateSaveState ¶
UpdateSaveState updates save_state and updated_at for the given game.
func (*Store) UpdateStatus ¶
func (s *Store) UpdateStatus(id int64, status GameStatus) error
UpdateStatus updates the status (and completed_at if completed) for the given game.