diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-12-27 12:40:19 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:58 +0100 |
| commit | 4e2ab55d345fd5e5c5d2d5bc56948611b15564d5 (patch) | |
| tree | c6998ac54687c442ad0baa541edd0fbf917b1308 /go/game/unit_test.go | |
| parent | 5aa8e7ddbc41aed55e7918e6afaec0b5c07fa510 (diff) | |
| download | muhqs-game-4e2ab55d345fd5e5c5d2d5bc56948611b15564d5.tar.gz muhqs-game-4e2ab55d345fd5e5c5d2d5bc56948611b15564d5.zip | |
introduce game.State interface abstraction
This allows to not use the internal game state directly from client
code.
Diffstat (limited to 'go/game/unit_test.go')
| -rw-r--r-- | go/game/unit_test.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/go/game/unit_test.go b/go/game/unit_test.go index deaeb5f6..fd9b95b4 100644 --- a/go/game/unit_test.go +++ b/go/game/unit_test.go @@ -17,20 +17,21 @@ symbols: S: street W: deep water ` - s := NewState() + s := NewLocalState() r := strings.NewReader(mapDef) - s.Map, _ = readMap(r) + m, _ := readMap(r) + s.SetMap(m) - s.AddNewPlayer("player", NewDeck()) - p := s.Players[0] + s.AddNewPlayer("player", NewDeck(), nil) + p := s.Players()[0] - f := NewUnit(NewCard("nautics/fisher"), s.Map.TileAt(Position{2, 2}), p) + f := NewUnit(NewCard("nautics/fisher"), s.Map().TileAt(Position{2, 2}), p) s.addPermanent(f) - a := NewUnit(NewCard("base/archer"), s.Map.TileAt(Position{1, 1}), p) + a := NewUnit(NewCard("base/archer"), s.Map().TileAt(Position{1, 1}), p) s.addPermanent(a) - sword := newEquipmentFromPath("base/sword", s.Map.TileAt(Position{0, 1}), p) + sword := newEquipmentFromPath("base/sword", s.Map().TileAt(Position{0, 1}), p) s.addPermanent(sword) movePermanent(a, f.Tile()) @@ -61,11 +62,11 @@ symbols: t.Fatalf("Piled archer is attackable") } - if len(a.AttackableTiles(s.Map)) != 0 { + if len(a.AttackableTiles(s.Map())) != 0 { t.Fatalf("Piled archer has attackable tiles") } - movePermanent(a, s.Map.TileAt(Position{1, 1})) + movePermanent(a, s.Map().TileAt(Position{1, 1})) if len(f.Pile()) != 0 { t.Fatalf("fisher's pile is not empty") } |
