aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-21 08:29:20 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:26 +0200
commit8d0e7f5f3faab22d2f96ed00ba89467f067fd9d9 (patch)
treedfd2720d253037cfe9a8bf5019fbdcb59e455ff0
parent80a44e1ee4c02dec693740b21383b71e0a9f5713 (diff)
downloadmuhqs-game-8d0e7f5f3faab22d2f96ed00ba89467f067fd9d9.tar.gz
muhqs-game-8d0e7f5f3faab22d2f96ed00ba89467f067fd9d9.zip
fix Target.AllowSelection for '*' avtions
-rw-r--r--go/game/targets.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/go/game/targets.go b/go/game/targets.go
index 1be206e7..bcb47d50 100644
--- a/go/game/targets.go
+++ b/go/game/targets.go
@@ -202,9 +202,11 @@ func (t *Target) AddSelection(sel any) (err error) {
return
}
-func (t *Target) RequireSelection() bool { return len(t.sel) < t.requirement.min }
-func (t *Target) HasSelection() bool { return len(t.sel) > 0 }
-func (t *Target) AllowSelection() bool { return len(t.sel) < t.requirement.max }
+func (t *Target) RequireSelection() bool { return len(t.sel) < t.requirement.min }
+func (t *Target) HasSelection() bool { return len(t.sel) > 0 }
+func (t *Target) AllowSelection() bool {
+ return (t.requirement.max == -1 || len(t.sel) < t.requirement.max) && len(t.Options()) > 0
+}
func (t *Target) ClearSelection() { t.sel = []interface{}{} }
func (t *Target) NoSelection() bool { return len(t.sel) == 0 }
func (t *Target) Selection() []interface{} { return t.sel }