feat: voting procedures

This commit is contained in:
Ilia Denisov
2026-01-30 12:18:32 +03:00
parent abf72c16b4
commit 824f6609ab
12 changed files with 581 additions and 18 deletions
+6 -5
View File
@@ -29,19 +29,20 @@ type Game struct {
Age uint `json:"turn"` // Game's turn number
Map Map `json:"map"`
Race []Race `json:"races"`
Votes float64 `json:"votes"`
ShipGroups []ShipGroup `json:"shipGroup,omitempty"`
Fleets []Fleet `json:"fleet,omitempty"`
}
func (g Game) Votes(raceID uuid.UUID) float64 {
// XXX: calculate [Race]Population once when loading Game from Storage?
var pop float64
// TODO: remove if not needed
func (g Game) RaceVotes(raceID uuid.UUID) float64 {
var result float64
for i := range g.Map.Planet {
if g.Map.Planet[i].Owner == raceID {
pop += g.Map.Planet[i].Population
result += g.Map.Planet[i].Votes()
}
}
return pop / 1000.
return result
}
func (g Game) MarshalBinary() (data []byte, err error) {