test dw distances

This commit is contained in:
Ilia Denisov
2025-09-23 23:33:47 +03:00
parent 7d93176031
commit ab822a1abf
7 changed files with 75 additions and 35 deletions
+2 -15
View File
@@ -7,6 +7,7 @@ import (
"github.com/google/uuid"
"github.com/iliadenisov/galaxy/pkg/generator"
"github.com/iliadenisov/galaxy/pkg/model/game"
"github.com/iliadenisov/galaxy/pkg/number"
)
type Repo interface {
@@ -198,7 +199,7 @@ func (sg ShipGroup) BombingPower() float64 {
sg.Weapons *
float64(sg.Type.Armament) *
float64(sg.Number)
return toFixed3(result)
return number.Fixed3(result)
}
// TODO: test this
@@ -211,17 +212,3 @@ func (fl Fleet) Speed() float64 {
}
return result
}
func round(num float64) int {
return int(num + math.Copysign(0.5, num))
}
// TODO: move to more common place
func toFixed(num float64, precision int) float64 {
output := math.Pow(10, float64(precision))
return float64(round(num*output)) / output
}
func toFixed3(num float64) float64 {
return toFixed(num, 3)
}