game generation process
This commit is contained in:
@@ -4,6 +4,18 @@ import "github.com/google/uuid"
|
||||
|
||||
type Game struct {
|
||||
ID uuid.UUID
|
||||
Age uint // Game's turn number
|
||||
Map Map
|
||||
Race []Race
|
||||
}
|
||||
|
||||
func (g Game) Votes(raceID uuid.UUID) float64 {
|
||||
// XXX: calculate [Race]Population once when loading Game from Storage?
|
||||
var pop float64
|
||||
for i := range g.Map.Planet {
|
||||
if g.Map.Planet[i].Owner == raceID {
|
||||
pop += g.Map.Planet[i].Population
|
||||
}
|
||||
}
|
||||
return pop / 1000.
|
||||
}
|
||||
|
||||
@@ -3,6 +3,5 @@ package game
|
||||
type Map struct {
|
||||
Width uint32
|
||||
Height uint32
|
||||
|
||||
Planet []Planet
|
||||
}
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
package game
|
||||
|
||||
import "math"
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Planet struct {
|
||||
X, Y float64
|
||||
Size float64
|
||||
|
||||
Name string
|
||||
Owner string
|
||||
Name string
|
||||
Number uint
|
||||
Owner uuid.UUID
|
||||
|
||||
Production ProductionType
|
||||
Resources float64 // Сырьё
|
||||
Industry float64 // Промышленность
|
||||
Population float64 // Население
|
||||
Population float64 // P - Население
|
||||
Industry float64 // I - Промышленность
|
||||
Resources float64 // R - Ресурсы / сырьё
|
||||
|
||||
Capital float64 // CAP $ - Запасы промышленности
|
||||
Material float64 // MAT M - Запасы сырья
|
||||
Material float64 // MAT M - Запасы ресурсов / сырья
|
||||
Colonists float64 // COL C - Количество колонистов
|
||||
// Параметр "L" означает количество свободных производственных единиц.
|
||||
// Параметр "L" - Свободный производственный потенциал
|
||||
}
|
||||
|
||||
// Производственный потенциал (I)
|
||||
// Свободный производственный потенциал (L)
|
||||
// промышленность * 0.75 + население * 0.25
|
||||
// TODO: за вычетом затрат, расходуемых в течение хода на модернизацию кораблей
|
||||
func (p Planet) ProductionCapacity() float64 {
|
||||
return p.Industry*0.75 + p.Population*0.25
|
||||
}
|
||||
|
||||
@@ -3,26 +3,27 @@ package game
|
||||
type PlanetProduction string
|
||||
|
||||
const (
|
||||
ProductionNone PlanetProduction = "NONE"
|
||||
ProductionMaterial PlanetProduction = "MAT"
|
||||
ProductionCapital PlanetProduction = "CAP"
|
||||
ProductionDrive PlanetProduction = "DRIVE"
|
||||
ProductionWeapons PlanetProduction = "WEAPONS"
|
||||
ProductionShields PlanetProduction = "SHIELDS"
|
||||
ProductionCargo PlanetProduction = "CARGO"
|
||||
ProductionNone PlanetProduction = "-"
|
||||
ProductionMaterial PlanetProduction = "MAT" // Сырьё
|
||||
ProductionCapital PlanetProduction = "CAP" // Промышленность
|
||||
|
||||
ProductionScience PlanetProduction = "SCIENCE"
|
||||
ProductionShip PlanetProduction = "SHIP"
|
||||
ResearchDrive PlanetProduction = "DRIVE"
|
||||
ResearchWeapons PlanetProduction = "WEAPONS"
|
||||
ResearchShields PlanetProduction = "SHIELDS"
|
||||
ResearchCargo PlanetProduction = "CARGO"
|
||||
|
||||
ResearchScience PlanetProduction = "SCIENCE"
|
||||
ProductionShip PlanetProduction = "SHIP"
|
||||
)
|
||||
|
||||
type ProductionType struct {
|
||||
Production PlanetProduction
|
||||
SubjectName string
|
||||
SubjectName string // TODO: change to UUID
|
||||
}
|
||||
|
||||
func (p PlanetProduction) AsType(subject string) ProductionType {
|
||||
switch p {
|
||||
case ProductionScience, ProductionShip:
|
||||
case ResearchScience, ProductionShip:
|
||||
return ProductionType{Production: p, SubjectName: subject}
|
||||
default:
|
||||
return ProductionType{Production: p}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package game
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
type Race struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Killed bool
|
||||
|
||||
Votes float64
|
||||
VoteFor string
|
||||
// Votes float64
|
||||
Ally uuid.UUID // Race's Votes receiver
|
||||
|
||||
Drive float64
|
||||
Weapons float64
|
||||
|
||||
Reference in New Issue
Block a user