well, fuck...

This commit is contained in:
Ilia Denisov
2025-09-28 09:17:17 +03:00
parent 66eeefc65d
commit 6510676237
8 changed files with 203 additions and 62 deletions
+32 -12
View File
@@ -51,6 +51,7 @@ func NewGameFromMap(r Repo, races []string, m generator.Map) (uuid.UUID, error)
Weapons: 1,
Shields: 1,
Cargo: 1,
// TODO: fill Relation
}
gameMap.Planet = append(gameMap.Planet, newPlanet(
planetCount,
@@ -104,23 +105,42 @@ func NewGameFromMap(r Repo, races []string, m generator.Map) (uuid.UUID, error)
g.Map = *gameMap
if err := r.SaveTurn(0, *g); err != nil {
return uuid.Nil, fmt.Errorf("persist: %s", err)
gg := *g
if err := r.SaveTurn(0, gg); err != nil {
return uuid.Nil, fmt.Errorf("save_turn: %s", err)
}
// if err := r.SaveState(gg); err != nil {
// return uuid.Nil, fmt.Errorf("save_state: %s", err)
// }
// TODO: save reports
// for i := range g.Race {
// }
// TODO: save battles
return g.ID, nil
}
func newPlanet(num uint, name string, owner uuid.UUID, x, y, size, pop, ind, res float64, prod game.ProductionType) game.Planet {
return game.Planet{
Name: name,
Number: num,
Owner: owner,
X: x,
Y: y,
Size: size,
Population: pop,
Industry: ind,
Resources: res,
Production: prod,
Owner: owner,
PlanetReport: game.PlanetReport{
UninhabitedPlanet: game.UninhabitedPlanet{
UnidentifiedPlanet: game.UnidentifiedPlanet{
X: x,
Y: y,
Number: num,
},
Size: size,
Name: name,
Resources: res,
},
Population: pop,
Industry: ind,
Production: prod,
},
}
}