aboutsummaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-17 13:40:42 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:50 +0100
commita96bbf10912495a041dcccfaaaa0ec5ee7860660 (patch)
treec9704926d9d7f6fe5f240e088c4cc863b91f6eac /go
parentedbbe6041628461e673bd7802932075692c0c25f (diff)
downloadmuhqs-game-a96bbf10912495a041dcccfaaaa0ec5ee7860660.tar.gz
muhqs-game-a96bbf10912495a041dcccfaaaa0ec5ee7860660.zip
implement targets candidates for hand cards
Diffstat (limited to 'go')
-rw-r--r--go/game/pileOfCards.go4
-rw-r--r--go/game/targets.go26
2 files changed, 20 insertions, 10 deletions
diff --git a/go/game/pileOfCards.go b/go/game/pileOfCards.go
index f88dfe93..5edae617 100644
--- a/go/game/pileOfCards.go
+++ b/go/game/pileOfCards.go
@@ -43,6 +43,10 @@ func (poc *PileOfCardsBase) Cards() []*Card {
return poc.cards
}
+func (poc *PileOfCardsBase) AddPoc(toAdd PileOfCards) {
+ poc.AddCards(toAdd.Cards())
+}
+
func (poc *PileOfCardsBase) AddCards(cards []*Card) {
for _, card := range cards {
poc.AddCard(card)
diff --git a/go/game/targets.go b/go/game/targets.go
index 2ef88665..75f3f53c 100644
--- a/go/game/targets.go
+++ b/go/game/targets.go
@@ -126,7 +126,7 @@ func (t *Target) HasSelection() bool { return len(t.sel) > 0 }
func (t *Target) ClearSelection() { t.sel = []interface{}{} }
func (t *Target) Options() (options []interface{}) {
- candidates := targetCandidates(t.desc, t.s)
+ candidates := t.candidates()
for _, candidate := range candidates {
if err := t.constraint(candidate); err == nil {
@@ -524,16 +524,22 @@ func parseCardTargetConstraint(desc string, s *State, action Action) []TargetCon
return constraints
}
-func targetCandidates(desc string, s *State) []interface{} {
- if strings.Contains(desc, "unit") ||
- strings.Contains(desc, "artifact") ||
- strings.Contains(desc, "permanent") {
-
- return utils.TypedSliceToInterfaceSlice(s.Permanents)
- } else if strings.Contains(desc, "tile") {
- return utils.TypedSliceToInterfaceSlice(s.Map.AllTiles())
+func (t *Target) candidates() []interface{} {
+ if strings.Contains(t.desc, "unit") ||
+ strings.Contains(t.desc, "artifact") ||
+ strings.Contains(t.desc, "permanent") {
+
+ 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" {
+ cards := NewPileOfCards()
+ for _, p := range t.s.Players {
+ cards.AddPoc(p.Hand)
+ }
+ return utils.TypedSliceToInterfaceSlice(cards.Cards())
}
- log.Panicf("Unimplemented target options for %s", desc)
+ log.Panicf("Unimplemented target options for %s", t.desc)
return nil
}