aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-04 13:09:36 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2023-02-04 13:12:55 +0100
commit3faa4eb9dabb72fcbf2a1f6bef9717a93a732d13 (patch)
tree37dba4bb374104cf5afd9e708aa2718888eb5e91
parent777252fb16dec5f0366f1529a923975b5daa9978 (diff)
downloadmuhqs-game-3faa4eb9dabb72fcbf2a1f6bef9717a93a732d13.tar.gz
muhqs-game-3faa4eb9dabb72fcbf2a1f6bef9717a93a732d13.zip
add distance > 0 assertion
-rw-r--r--go/game/range.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/go/game/range.go b/go/game/range.go
index 6e04d21f..bb60b54c 100644
--- a/go/game/range.go
+++ b/go/game/range.go
@@ -1,6 +1,7 @@
package game
import (
+ "log"
"math"
)
@@ -15,6 +16,9 @@ func DistanceBetweenPositions(origin, pos Position) int {
abs = ay + math.Floor(ax/2)
}
+ if int(abs) < 0 {
+ log.Fatalf("Distance smaller than 0")
+ }
return int(abs)
}