diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-21 08:29:20 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-07-22 12:54:28 -0400 |
| commit | 9c858593923b27a04459d86e5df630d6c96b8a45 (patch) | |
| tree | 22ac66b00eafb05d5f1de348cca26eb78ae4eab2 | |
| parent | f6d557d1ba93c7b578733a2d2da6c92f5e3c649c (diff) | |
| download | muhqs-game-9c858593923b27a04459d86e5df630d6c96b8a45.tar.gz muhqs-game-9c858593923b27a04459d86e5df630d6c96b8a45.zip | |
fix Target.AllowSelection for '*' avtions
| -rw-r--r-- | go/game/targets.go | 8 |
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 } |
