From 4e2ab55d345fd5e5c5d2d5bc56948611b15564d5 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 27 Dec 2024 12:40:19 +0100 Subject: introduce game.State interface abstraction This allows to not use the internal game state directly from client code. --- go/game/unit_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'go/game/unit_test.go') 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") } -- cgit v1.2.3