aboutsummaryrefslogtreecommitdiff
path: root/go/game/unit_test.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-22 18:35:16 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-07-24 12:22:10 -0400
commit43306199e6405f08ff1446b1bd8c6fb8850f465f (patch)
treeefdac0bff87db44c2b6413b17eab506133da3026 /go/game/unit_test.go
parent7affd79b884d87c93c53e87056a1d5b74f669497 (diff)
downloadmuhqs-game-43306199e6405f08ff1446b1bd8c6fb8850f465f.tar.gz
muhqs-game-43306199e6405f08ff1446b1bd8c6fb8850f465f.zip
implement tower tile effect
Diffstat (limited to 'go/game/unit_test.go')
-rw-r--r--go/game/unit_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/go/game/unit_test.go b/go/game/unit_test.go
index f2a15ddc..e707c560 100644
--- a/go/game/unit_test.go
+++ b/go/game/unit_test.go
@@ -79,3 +79,53 @@ symbols:
t.Fatalf("archer's mele attack is not 2")
}
}
+
+func TestAttackablePerms(t *testing.T) {
+ mapDef := `map: |1-
+ HST
+ HSF
+ TSW
+symbols:
+ T: tower
+ H: house
+ F: farm
+ S: street
+ W: deep water
+`
+ s := NewLocalState()
+ r := strings.NewReader(mapDef)
+ m, _ := readMap(r)
+ s.SetMap(m)
+
+ p := s.AddNewPlayer("player", NewDeck())
+ o := s.AddNewPlayer("opponent", NewDeck())
+
+ a := s.addNewUnit(NewCard("base/archer"), Position{2, 0}, p)
+ units := []*Unit{}
+ for x := range 3 {
+ for y := range 3 {
+ var u *Unit
+ pos := Position{x, y}
+ if x == 2 && y == 0 {
+ continue
+ } else if x == 2 && y == 2 {
+ u = s.addNewUnit(NewCard("nautics/fisher"), pos, o)
+ } else {
+ u = s.addNewUnit(NewCard("misc/farmer"), pos, o)
+ }
+ units = append(units, u)
+ }
+ }
+
+ aTiles := a.AttackableTiles(m)
+ is := len(aTiles)
+ if is != 6 {
+ t.Fatal("6 attackable tiles expected not:", is)
+ }
+
+ aPerms := a.AttackableEnemyPermanents(m)
+ is = len(aPerms)
+ if is != 6 {
+ t.Fatal("6 attackable permanents expected not:", is)
+ }
+}