diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-17 14:36:06 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:50:11 +0200 |
| commit | 50b9a042435b324be281b78ceb87dd63fd24acba (patch) | |
| tree | 06d7436f7cb6963894ddcb767658e472474c9d67 /go/game | |
| parent | d52a41bdcb587abe57f7d581d260b4be948dcc2a (diff) | |
| download | muhqs-game-50b9a042435b324be281b78ceb87dd63fd24acba.tar.gz muhqs-game-50b9a042435b324be281b78ceb87dd63fd24acba.zip | |
use prompt for target selection of all actions
Diffstat (limited to 'go/game')
| -rw-r--r-- | go/game/targets.go | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/go/game/targets.go b/go/game/targets.go index 75f3f53c..df522565 100644 --- a/go/game/targets.go +++ b/go/game/targets.go @@ -121,9 +121,11 @@ func (t *Target) AddSelection(sel interface{}) (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) ClearSelection() { t.sel = []interface{}{} } +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) ClearSelection() { t.sel = []interface{}{} } +func (t *Target) Selection() []interface{} { return t.sel } func (t *Target) Options() (options []interface{}) { candidates := t.candidates() @@ -172,7 +174,9 @@ func (t *Targets) ClearSelections() { } } func (t *Targets) Options() (options []interface{}) { return t.ts[t.idx].Options() } +func (t *Targets) Cur() *Target { return t.ts[t.idx] } func (t *Targets) Next() { t.idx++ } +func (t *Targets) Targets() []*Target { return t.ts } func (t *Targets) CheckTargets(s *State) error { for _, target := range t.ts { @@ -532,10 +536,25 @@ func (t *Target) candidates() []interface{} { return utils.TypedSliceToInterfaceSlice(t.s.Permanents) } else if strings.Contains(t.desc, "tile") { return utils.TypedSliceToInterfaceSlice(t.s.Map.AllTiles()) - } else if t.desc == "hand card" { + } else if strings.Contains(t.desc, "card") { cards := NewPileOfCards() - for _, p := range t.s.Players { - cards.AddPoc(p.Hand) + switch t.desc { + case "hand card": + for _, p := range t.s.Players { + cards.AddPoc(p.Hand) + } + case "store card": + if t.s.Map.HasStores() { + for _, store := range t.s.Map.Stores { + cards.AddPoc(store) + } + } else { + for _, p := range t.s.Players { + cards.AddPoc(p.Store) + } + } + default: + log.Panicf("Unimplemented card options for %s", t.desc) } return utils.TypedSliceToInterfaceSlice(cards.Cards()) } |
