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
+13 -5
View File
@@ -1,12 +1,16 @@
package game
import "github.com/google/uuid"
import (
"encoding/json"
"github.com/google/uuid"
)
type Game struct {
ID uuid.UUID
Age uint // Game's turn number
Map Map
Race []Race
ID uuid.UUID `json:"id"`
Age uint `json:"turn"` // Game's turn number
Map Map `json:"map"`
Race []Race `json:"races"`
}
func (g Game) Votes(raceID uuid.UUID) float64 {
@@ -19,3 +23,7 @@ func (g Game) Votes(raceID uuid.UUID) float64 {
}
return pop / 1000.
}
func (g Game) MarshalBinary() (data []byte, err error) {
return json.Marshal(&g)
}