test dw distances
This commit is contained in:
+2
-15
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user