aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-03-26 21:31:47 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:56 +0100
commit46819d5eb7ce7dd174db9eba254eed583adbf01a (patch)
treee4963858dc5babc2535233a5eeb6f029d31e1d86
parente82bce56827e5a43c02895feef86394f39f319d7 (diff)
downloadmuhqs-game-46819d5eb7ce7dd174db9eba254eed583adbf01a.tar.gz
muhqs-game-46819d5eb7ce7dd174db9eba254eed583adbf01a.zip
check if Targets allow a selection
This fixes highlighting when an action needs no targets at all.
-rw-r--r--go/client/game.go2
-rw-r--r--go/game/targets.go10
2 files changed, 11 insertions, 1 deletions
diff --git a/go/client/game.go b/go/client/game.go
index 4d265e4b..8c7d50ad 100644
--- a/go/client/game.go
+++ b/go/client/game.go
@@ -501,7 +501,7 @@ func (g *Game) handleSelection(obj interface{}, x, y int) {
case ui.HandCard:
a := game.NewPlayAction(g.activePlayer, obj.C)
targets := a.Targets()
- if targets != nil && targets.Cur().AllowSelection() {
+ if targets != nil && targets.AllowSelection() {
g.addPrompt(a, fmt.Sprintf("Select targets to play %v", obj.C.Name))
g.handLayer.HighlightCard(obj.C, ui.HighlightSelectionColor)
} else {
diff --git a/go/game/targets.go b/go/game/targets.go
index fb393057..58f19dc1 100644
--- a/go/game/targets.go
+++ b/go/game/targets.go
@@ -271,6 +271,16 @@ func (targets *Targets) RequireSelection() bool {
return false
}
+func (targets *Targets) AllowSelection() bool {
+ for _, t := range targets.ts {
+ if t.AllowSelection() {
+ return true
+ }
+ }
+
+ return false
+}
+
func conjunction(constraints ...TargetConstraintFunc) TargetConstraintFunc {
return func(t interface{}) error {
for _, constraint := range constraints {