refactor: floats, tests

This commit is contained in:
Ilia Denisov
2026-02-04 18:33:38 +02:00
parent 9d46abe805
commit 6a603ea9ad
37 changed files with 381 additions and 722 deletions
+8 -8
View File
@@ -7,11 +7,11 @@ import (
type ShipType struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Drive float64 `json:"drive"`
Drive Float `json:"drive"`
Armament uint `json:"armament"`
Weapons float64 `json:"weapons"`
Shields float64 `json:"shields"`
Cargo float64 `json:"cargo"`
Weapons Float `json:"weapons"`
Shields Float `json:"shields"`
Cargo Float `json:"cargo"`
}
func (st ShipType) Equal(o ShipType) bool {
@@ -38,22 +38,22 @@ func (st ShipType) BlockMass(t Tech) float64 {
}
func (st ShipType) DriveBlockMass() float64 {
return st.Drive
return st.Drive.F()
}
func (st ShipType) WeaponsBlockMass() float64 {
if st.Armament == 0 || st.Weapons == 0 {
return 0
}
return float64(st.Armament+1) * (st.Weapons / 2)
return float64(st.Armament+1) * (st.Weapons.F() / 2)
}
func (st ShipType) ShieldsBlockMass() float64 {
return st.Shields
return st.Shields.F()
}
func (st ShipType) CargoBlockMass() float64 {
return st.Cargo
return st.Cargo.F()
}
func (st ShipType) EmptyMass() float64 {