ui calculator
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"iter"
|
||||
"slices"
|
||||
|
||||
"galaxy/calc"
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
@@ -272,7 +273,7 @@ func ProduceShip(p *game.Planet, productionAvailable, shipMass float64) uint {
|
||||
}
|
||||
ships := uint(0)
|
||||
pa := productionAvailable
|
||||
PRODcost := ShipProductionCost(shipMass)
|
||||
PRODcost := calc.ShipProductionCost(shipMass)
|
||||
var MATneed, MATfarm, totalCost float64
|
||||
for {
|
||||
MATneed = shipMass - float64(p.Material)
|
||||
@@ -281,8 +282,6 @@ func ProduceShip(p *game.Planet, productionAvailable, shipMass float64) uint {
|
||||
}
|
||||
MATfarm = MATneed / float64(p.Resources)
|
||||
totalCost = PRODcost + MATfarm
|
||||
// fmt.Printf("PRODcost: %3.03f MATcost: %3.03f MAThave: %3.03f MATneed: %3.03f MATfarm: %3.03f total: %3.03f \n",
|
||||
// PRODcost, shipMass, float64(p.Material), MATneed, MATfarm, totalCost)
|
||||
if pa < totalCost {
|
||||
progress := pa / totalCost
|
||||
pval := game.F(progress)
|
||||
@@ -292,7 +291,6 @@ func ProduceShip(p *game.Planet, productionAvailable, shipMass float64) uint {
|
||||
p.Production.Progress = &pval
|
||||
fval := game.F(pa)
|
||||
p.Production.ProdUsed = &fval
|
||||
// fmt.Println("pa", pa, "progress", progress, "MAT:", progress*shipMass)
|
||||
return ships
|
||||
} else {
|
||||
pa -= totalCost
|
||||
@@ -301,10 +299,3 @@ func ProduceShip(p *game.Planet, productionAvailable, shipMass float64) uint {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ShipProductionCost(shipMass float64) float64 {
|
||||
return shipMass * 10.
|
||||
}
|
||||
func ShipMaterialCost(shipMass, planetResource float64) float64 {
|
||||
return shipMass / planetResource
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user