aboutsummaryrefslogtreecommitdiff
path: root/go/game/targets_test.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-08-19 15:37:09 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:40 +0200
commit3d36f5c92ec204f72d55df5b41e9bacdf5e87ba8 (patch)
tree25f8ce5b91b34e6f56380f1c1a32fcd08ff8d419 /go/game/targets_test.go
parent790706dbf1e797607dfb6c6717ab863a9e4cb5ca (diff)
downloadmuhqs-game-3d36f5c92ec204f72d55df5b41e9bacdf5e87ba8.tar.gz
muhqs-game-3d36f5c92ec204f72d55df5b41e9bacdf5e87ba8.zip
fix spawn tile constraint for water spawns
This is not a general solution because spawns could be a valid tile type constraint as well as meaning available spawn tiles. The separation and a clean implementation is still a TODO.
Diffstat (limited to 'go/game/targets_test.go')
-rw-r--r--go/game/targets_test.go67
1 files changed, 66 insertions, 1 deletions
diff --git a/go/game/targets_test.go b/go/game/targets_test.go
index ae451dbf..eed94f4f 100644
--- a/go/game/targets_test.go
+++ b/go/game/targets_test.go
@@ -9,7 +9,7 @@ func TestTileTargets(t *testing.T) {
mapDef := `map: |1-
HSTS
HSFS
- TSWS
+ TSWD
symbols:
T: tower
@@ -17,6 +17,7 @@ symbols:
F: farm
S: street
W: deep water
+ D: docks
`
s := NewLocalState()
r := strings.NewReader(mapDef)
@@ -72,6 +73,70 @@ symbols:
if len(opts) != 6 {
t.Fatal("expected 6 available candidates not:", len(opts))
}
+
+ fisher := NewCard("nautics/fisher")
+ p.Hand.AddCard(fisher)
+ pa := NewPlayAction(p, fisher)
+ opts = pa.Target().Options()
+ if len(opts) != 1 {
+ t.Fatal("expected 1 available candidates not:", len(opts))
+ }
+}
+
+func TestSpawnTargets(t *testing.T) {
+ s := NewLocalState()
+ m, _ := GetMap("the-kraken")
+ s.SetMap(m)
+
+ s.activePhase = actionPhase
+
+ p := s.AddNewPlayer("player", NewDeck())
+ ctrl := newMockPlayerControl(p)
+ ctrl.actionToSend = NewPassPriority(p)
+ p.Ctrl = ctrl
+
+ p.gainResource(2)
+
+ farmer := NewCard("misc/farmer")
+ p.Hand.AddCard(farmer)
+ fisher := NewCard("nautics/fisher")
+ p.Hand.AddCard(fisher)
+
+ pa := NewPlayAction(p, farmer)
+ if !pa.Target().RequireSelection() {
+ t.Fatal("playing farmer has not require selection")
+ }
+ if !pa.Target().AllowSelection() {
+ t.Fatal("playing farmer has no valid targets")
+ }
+ farmerPos := Position{3, 13}
+ err := pa.Target().AddSelection(m.TileAt(farmerPos))
+ if err != nil {
+ t.Fatal("Not allowed to play farmer at:", farmerPos)
+ }
+ s.declareAction(pa)
+ if s.stack.IsEmpty() {
+ t.Fatal("farmer play action not declared")
+ }
+ s.stack.resolve()
+
+ pa2 := NewPlayAction(p, fisher)
+ if !pa2.Target().RequireSelection() {
+ t.Fatal("playing fisher has not require selection")
+ }
+ if !pa2.Target().AllowSelection() {
+ t.Fatal("playing fisher has no valid targets")
+ }
+ fisherPos := Position{3, 10}
+ pa2.Target().AddSelection(m.TileAt(fisherPos))
+ if err != nil {
+ t.Fatal("Not allowed to play fisher at:", fisherPos)
+ }
+ s.declareAction(pa2)
+ if s.stack.IsEmpty() {
+ t.Fatal("fisher play action not declared")
+ }
+ s.stack.resolve()
}
func TestFlexAttackTargets(t *testing.T) {