feat: voting procedures
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user