aboutsummaryrefslogtreecommitdiff
path: root/go/game/map_test.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-24 05:25:12 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:29 +0200
commitbfec366ed246ad56860b564fc648a74d71d8ec10 (patch)
tree03618f0f0b4cb32a458b199d9e798951104a194a /go/game/map_test.go
parent007d8a85c892f2dbdf51404ff3794d0b3313ab36 (diff)
downloadmuhqs-game-bfec366ed246ad56860b564fc648a74d71d8ec10.tar.gz
muhqs-game-bfec366ed246ad56860b564fc648a74d71d8ec10.zip
support street actions
Diffstat (limited to 'go/game/map_test.go')
-rw-r--r--go/game/map_test.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/go/game/map_test.go b/go/game/map_test.go
index 15fa05cb..bc17dd55 100644
--- a/go/game/map_test.go
+++ b/go/game/map_test.go
@@ -4,6 +4,8 @@ import (
"reflect"
"strings"
"testing"
+
+ "golang.org/x/exp/slices"
)
func parseMapString(t *testing.T, mapDef string) *Map {
@@ -113,3 +115,45 @@ symbols:
t.Fatal("Tile at (0,0) is not a house")
}
}
+
+func TestMovementRangeTiles(t *testing.T) {
+ mapDef := `map: |1-
+ T H HT
+ FSSSSS2H
+ SHSH HS
+ S SST S
+ H HFH H
+ S TSS S
+ SH HSHS
+ H1SSSSSF
+ TH H T
+
+symbols:
+ T: tower
+ H: house
+ F: farm
+ S: street
+ 1: spawn player 1
+ 2: spawn player 2
+`
+
+ s := NewLocalState()
+ m := parseMapString(t, mapDef)
+ s.SetMap(m)
+ p := s.AddNewPlayer("p", NewDeck())
+ o := Position{2, 2}
+ a := s.addNewUnit(NewCard("base/archer"), o, p)
+
+ tiles := a.MoveRangeTiles()
+ exp := TilesInRange(m, a, a.Movement.Range)
+
+ if len(tiles) != len(exp) {
+ t.Fatal("expected", len(exp), "tiles not", len(tiles))
+ }
+
+ for _, tile := range exp {
+ if !slices.Contains(tiles, tile) {
+ t.Fatal("missing", tile, "in tiles")
+ }
+ }
+}