saving new turn

This commit is contained in:
Ilia Denisov
2025-09-26 01:38:49 +03:00
parent 6d87ea6086
commit 282150a253
13 changed files with 170 additions and 57 deletions
+3 -3
View File
@@ -10,7 +10,7 @@ import (
)
type Repo interface {
Persist(game.Game) error
SaveTurn(uint, game.Game) error
}
func NewGame(r Repo, races []string) (uuid.UUID, error) {
@@ -46,7 +46,7 @@ func NewGame(r Repo, races []string) (uuid.UUID, error) {
g.Race[i] = game.Race{
ID: raceID,
Name: races[i],
Ally: raceID,
Vote: raceID,
Drive: 1,
Weapons: 1,
Shields: 1,
@@ -104,7 +104,7 @@ func NewGame(r Repo, races []string) (uuid.UUID, error) {
g.Map = *gameMap
if err := r.Persist(*g); err != nil {
if err := r.SaveTurn(0, *g); err != nil {
return uuid.Nil, fmt.Errorf("persist: %s", err)
}
return g.ID, nil