aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-28 18:30:43 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-07-28 18:30:43 +0200
commitf7144b07bd199624d9087900be4569a5c8abb17d (patch)
treea41e3abcc38721b1ffda960891f2bbce632a3eec
parent5f93c27f8124e99d2464b1b1cacf9af101145715 (diff)
downloadmuhqs-game-f7144b07bd199624d9087900be4569a5c8abb17d.tar.gz
muhqs-game-f7144b07bd199624d9087900be4569a5c8abb17d.zip
add pioneer implementation test case
-rw-r--r--go/game/cardImplementations_test.go65
1 files changed, 65 insertions, 0 deletions
diff --git a/go/game/cardImplementations_test.go b/go/game/cardImplementations_test.go
new file mode 100644
index 00000000..1ad7e142
--- /dev/null
+++ b/go/game/cardImplementations_test.go
@@ -0,0 +1,65 @@
+package game
+
+import (
+ "log"
+ "strings"
+ "testing"
+
+ "muhq.space/muhqs-game/go/utils"
+)
+
+func TestPioneerFullAction(t *testing.T) {
+ mapDef := `map: |1-
+ HST
+ H H
+ FW
+symbols:
+ T: tower
+ H: house
+ F: farm
+ S: street
+ W: deep water
+`
+ s := NewLocalState()
+
+ m, _ := readMap(strings.NewReader(mapDef))
+ s.SetMap(m)
+
+ player := s.AddNewPlayer("p", NewDeck())
+
+ p := s.addNewUnit(NewCard("base/pioneer"), Position{1, 1}, player)
+ sword := s.addNewEquipment(NewCard("base/sword"), Position{0, 1}, player)
+ palisade := s.addNewArtifact(NewCard("base/palisade"), Position{0, 0}, player)
+
+ a := p.FullActions[0]
+ opts := a.Target().Options()
+ if len(opts) != 11 {
+ log.Printf("%q\n", opts)
+ t.Fatal("expexted 11 targets to neutralize")
+ }
+
+ if !utils.InterfaceSliceContains(opts, sword) {
+ t.Fatal("sword is missing")
+ }
+
+ if !utils.InterfaceSliceContains(opts, palisade) {
+ t.Fatal("palisade is missing")
+ }
+
+ a.Target().AddSelection(m.TileAt(Position{0, 1}))
+ s.ResolveAction(a)
+ if m.TileAt(Position{0, 1}).Type != TileTypes.Neutral {
+ t.Fatal("tile not neutralized")
+ }
+
+ a = p.FullActions[0]
+ if len(a.Target().Selection()) != 0 {
+ t.Fatal("full action still has target selection")
+ }
+
+ a.Target().AddSelection(palisade)
+ s.ResolveAction(a)
+ if m.TileAt(Position{0, 0}).Permanent != nil {
+ t.Fatal("palisade not destroyed")
+ }
+}