mirror of
https://github.com/tiennm99/gomoku.git
synced 2026-05-24 10:25:13 +00:00
acf08669dd
- Split monolithic database.go/model.go/gomoku.go into focused files: player.go, room.go, store.go, errors.go, events.go, cleanup.go - NewRoom embeds game.Board directly; carries blackPlayerId, whitePlayerId, currentTurn, moveHistory, spectators, owner, type, difficulty from caro domain - Store singleton with sync.RWMutex: RegisterPlayer, CreatePvpRoom, CreatePveRoom, JoinNewRoom, LeaveNewRoom, WatchNewRoom, UnwatchNewRoom, BroadcastToNewRoom - PVE rooms randomly assign human to Black or White; AI takes opposite side - legacy.go shim keeps server/state/*.go and state/game/gomoku.go compiling without modification until phase-06 rewrites them - consts/const.go: add RoomTypePvp/Pve, Status*, RoomStatus*, Difficulty* enums
15 lines
569 B
Go
15 lines
569 B
Go
// Package database provides the in-memory domain model and store for the Gomoku server.
|
|
// All state is volatile — server restart clears everything.
|
|
package database
|
|
|
|
import "errors"
|
|
|
|
// Exported sentinel errors for store operations.
|
|
var (
|
|
ErrRoomNotFound = errors.New("room not found")
|
|
ErrRoomFull = errors.New("room is full")
|
|
ErrRoomPlaying = errors.New("room is already playing")
|
|
ErrInvalidDifficulty = errors.New("difficulty must be 1 (easy), 2 (medium), or 3 (hard)")
|
|
ErrNotOwner = errors.New("player is not the room owner")
|
|
)
|