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
+4 -4
View File
@@ -22,11 +22,11 @@ func (f Float) F() float64 {
return float64(f)
}
type TechSet map[Tech]float64
type TechSet map[Tech]Float
func (ts TechSet) Value(t Tech) float64 {
if v, ok := ts[t]; ok {
return v
return v.F()
} else {
panic(fmt.Sprintf("TechSet: Value: %s's value not set", t.String()))
}
@@ -34,7 +34,7 @@ func (ts TechSet) Value(t Tech) float64 {
func (ts TechSet) Set(t Tech, v float64) TechSet {
m := maps.Clone(ts)
m[t] = v
m[t] = F(v)
return m
}
@@ -44,7 +44,7 @@ type Game struct {
Turn uint `json:"turn"`
Map Map `json:"map"`
Race []Race `json:"races"`
Votes float64 `json:"votes"`
Votes Float `json:"votes"`
ShipGroups []ShipGroup `json:"shipGroup,omitempty"`
Fleets []Fleet `json:"fleet,omitempty"`
Winner []uuid.UUID `json:"winner,omitempty"`