aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-22 11:12:16 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:27 +0200
commit181b38d96fbc13c7d8429eaeef5610b98f99c38c (patch)
treeec06ea27240098d4e56c966001b5eb8e21f3a2c1
parent1e55e38eb86ee0282676e1a2f3ba56f168f3d178 (diff)
downloadmuhqs-game-181b38d96fbc13c7d8429eaeef5610b98f99c38c.tar.gz
muhqs-game-181b38d96fbc13c7d8429eaeef5610b98f99c38c.zip
add unit assertion
-rw-r--r--go/game/unit.go7
-rw-r--r--go/game/unit_test.go3
2 files changed, 8 insertions, 2 deletions
diff --git a/go/game/unit.go b/go/game/unit.go
index 75015a30..85c6b97c 100644
--- a/go/game/unit.go
+++ b/go/game/unit.go
@@ -1,5 +1,9 @@
package game
+import (
+ "log"
+)
+
const (
DEFAULT_AVAIL_MOVE_ACTIONS = 1
DEFAULT_AVAIL_ATTACK_ACTIONS = 1
@@ -21,6 +25,9 @@ type Unit struct {
}
func NewUnit(card *Card, tile *Tile, owner *Player) *Unit {
+ if card.Type != CardTypes.Unit {
+ log.Panic(card.Name, " is not a unit")
+ }
var movement Movement
movementDesc, found := card.Values["movement"]
if !found {
diff --git a/go/game/unit_test.go b/go/game/unit_test.go
index b6a6f59a..f2a15ddc 100644
--- a/go/game/unit_test.go
+++ b/go/game/unit_test.go
@@ -22,8 +22,7 @@ symbols:
m, _ := readMap(r)
s.SetMap(m)
- s.AddNewPlayer("player", NewDeck())
- p := s.Players()[0]
+ p := s.AddNewPlayer("player", NewDeck())
f := NewUnit(NewCard("nautics/fisher"), s.Map().TileAt(Position{2, 2}), p)
s.addPermanent(f)