use float64

This commit is contained in:
Ilia Denisov
2025-09-23 22:27:09 +03:00
parent 1a1bd0af17
commit 7d93176031
9 changed files with 60 additions and 60 deletions
+10 -10
View File
@@ -3,26 +3,26 @@ package game
import "math"
type Planet struct {
X, Y float32
Size float32
X, Y float64
Size float64
Name string
Owner string
Production ProductionType
Resources float32 // Сырьё
Industry float32 // Промышленность
Population float32 // Население
Resources float64 // Сырьё
Industry float64 // Промышленность
Population float64 // Население
Capital float32 // CAP $ - Запасы промышленности
Material float32 // MAT M - Запасы сырья
Colonists float32 // COL C - Количество колонистов
Capital float64 // CAP $ - Запасы промышленности
Material float64 // MAT M - Запасы сырья
Colonists float64 // COL C - Количество колонистов
// Параметр "L" означает количество свободных производственных единиц.
}
// Производственный потенциал (I)
// промышленность * 0.75 + население * 0.25
func (p Planet) ProductionCapacity() float32 {
func (p Planet) ProductionCapacity() float64 {
return p.Industry*0.75 + p.Population*0.25
}
@@ -30,7 +30,7 @@ func (p Planet) ProductionCapacity() float32 {
// TODO: test on real values
func (p *Planet) IncreaseIndustry() {
prod := p.ProductionCapacity() / 5
industryIncrement := float32(math.Min(float64(prod), float64(p.Material)))
industryIncrement := math.Min(prod, p.Material)
p.Industry += industryIncrement
if p.Industry > p.Population {
p.Industry = p.Population
+7 -7
View File
@@ -4,19 +4,19 @@ type Race struct {
Name string
Killed bool
Votes float32
Votes float64
VoteFor string
Drive float32
Weapons float32
Shields float32
Cargo float32
Drive float64
Weapons float64
Shields float64
Cargo float64
}
func (r Race) FlightDistance() float32 {
func (r Race) FlightDistance() float64 {
return r.Drive * 40
}
func (r Race) VisibilityDistance() float32 {
func (r Race) VisibilityDistance() float64 {
return r.Drive * 30
}