diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-22 11:12:16 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-07-22 12:54:28 -0400 |
| commit | dccae564f4e2c99a1352eedfbb0bba510b35dab9 (patch) | |
| tree | 833762eecbf2ae27dc647c5cd90c7f34d5331ca8 | |
| parent | 1eacb0795451a4cf267a091b6b66e182d3c47bcf (diff) | |
| download | muhqs-game-dccae564f4e2c99a1352eedfbb0bba510b35dab9.tar.gz muhqs-game-dccae564f4e2c99a1352eedfbb0bba510b35dab9.zip | |
add unit assertion
| -rw-r--r-- | go/game/unit.go | 7 | ||||
| -rw-r--r-- | go/game/unit_test.go | 3 |
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) |
