refactor: fleet/group AtPlanet
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"maps"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/number"
|
||||
)
|
||||
|
||||
type Float float64
|
||||
@@ -19,7 +20,7 @@ func (f Float) Add(v float64) Float {
|
||||
}
|
||||
|
||||
func (f Float) F() float64 {
|
||||
return float64(f)
|
||||
return number.Fixed12(float64(f))
|
||||
}
|
||||
|
||||
type TechSet map[Tech]Float
|
||||
|
||||
@@ -142,8 +142,7 @@ func (sg ShipGroup) State() ShipGroupState {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: ambigous func, refactor
|
||||
func (sg ShipGroup) OnPlanet() (uint, bool) {
|
||||
func (sg ShipGroup) AtPlanet() (uint, bool) {
|
||||
switch sg.State() {
|
||||
case StateInOrbit:
|
||||
return sg.Destination, true
|
||||
@@ -171,7 +170,7 @@ func (sg ShipGroup) Equal(other ShipGroup) bool {
|
||||
sg.TechLevel(TechShields) == other.TechLevel(TechShields) &&
|
||||
sg.TechLevel(TechCargo) == other.TechLevel(TechCargo) &&
|
||||
sg.CargoType == other.CargoType &&
|
||||
sg.Load.F()/float64(sg.Number) == other.Load.F()/float64(other.Number) &&
|
||||
(sg.Load/F(float64(sg.Number))).F() == (other.Load/F(float64(other.Number))).F() &&
|
||||
sg.State() == other.State()
|
||||
}
|
||||
|
||||
|
||||
@@ -244,6 +244,6 @@ func TestShipGroupEqual(t *testing.T) {
|
||||
|
||||
// dirty hack to equalize loads
|
||||
left.Number = 5
|
||||
left.Load = game.F(right.Load.F() / float64(right.Number) * float64(left.Number))
|
||||
left.Load = game.F(float64(right.Load) / float64(right.Number) * float64(left.Number))
|
||||
assert.True(t, left.Equal(right))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user