refactor: planet industry production

This commit is contained in:
Ilia Denisov
2026-02-08 20:12:27 +02:00
parent b928bb2976
commit f8412be248
4 changed files with 14 additions and 37 deletions
+1 -19
View File
@@ -113,7 +113,7 @@ type ShipGroup struct {
CargoType *CargoType `json:"loadType,omitempty"` //
Load Float `json:"load"` // Cargo loaded - "Масса груза"
Tech TechSet `json:"tech"` //
Destination uint `json:"destination"` // TODO: TEST: Destination, Origin, Range
Destination uint `json:"destination"` //
StateInSpace *InSpace `json:"inSpace,omitempty"` //
StateUpgrade *InUpgrade `json:"upgrade,omitempty"` //
StateTransfer bool `json:"transfer,omitempty"` //
@@ -123,7 +123,6 @@ func (sg ShipGroup) TechLevel(t Tech) Float {
return F(sg.Tech.Value(t))
}
// TODO: refactor to separate method with *ShipGroup as parameter
func (sg *ShipGroup) SetTechLevel(t Tech, v float64) {
sg.Tech = sg.Tech.Set(t, v)
}
@@ -213,23 +212,6 @@ func (sg ShipGroup) Speed(st *ShipType) float64 {
return sg.DriveEffective(st) * 20 / sg.FullMass(st)
}
func (sg ShipGroup) UpgradeDriveCost(st *ShipType, drive float64) float64 {
return (1 - sg.TechLevel(TechDrive).F()/drive) * 10 * st.Drive.F()
}
// TODO: test on other values
func (sg ShipGroup) UpgradeWeaponsCost(st *ShipType, weapons float64) float64 {
return (1 - sg.TechLevel(TechWeapons).F()/weapons) * 10 * st.WeaponsBlockMass()
}
func (sg ShipGroup) UpgradeShieldsCost(st *ShipType, shields float64) float64 {
return (1 - sg.TechLevel(TechShields).F()/shields) * 10 * st.Shields.F()
}
func (sg ShipGroup) UpgradeCargoCost(st *ShipType, cargo float64) float64 {
return (1 - sg.TechLevel(TechCargo).F()/cargo) * 10 * st.Cargo.F()
}
// Мощность бомбардировки
func (sg ShipGroup) BombingPower(st *ShipType) float64 {
return (math.Sqrt(st.Weapons.F()*sg.TechLevel(TechWeapons).F())/10. + 1.) *