aboutsummaryrefslogtreecommitdiff
path: root/go/game
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-17 14:36:06 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:51 +0100
commit14f7b0274a20ffc8189d18de5031defcc15e9890 (patch)
tree7eda383eaa29566a94a4df87f2fb74ff047a59ec /go/game
parenta96bbf10912495a041dcccfaaaa0ec5ee7860660 (diff)
downloadmuhqs-game-14f7b0274a20ffc8189d18de5031defcc15e9890.tar.gz
muhqs-game-14f7b0274a20ffc8189d18de5031defcc15e9890.zip
use prompt for target selection of all actions
Diffstat (limited to 'go/game')
-rw-r--r--go/game/targets.go31
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())
}