diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-08 12:01:58 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:50:08 +0200 |
| commit | c35ccce84a1fa086b91dfe9f05169e39dd507c76 (patch) | |
| tree | 88e0166305085d320785f62a0b9e384d646e4115 | |
| parent | 39ce353b61d12f0e5bd31f83d7042bcfa7d8a364 (diff) | |
| download | muhqs-game-c35ccce84a1fa086b91dfe9f05169e39dd507c76.tar.gz muhqs-game-c35ccce84a1fa086b91dfe9f05169e39dd507c76.zip | |
add Contains check for PileOfCards
| -rw-r--r-- | go/game/pileOfCards.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/go/game/pileOfCards.go b/go/game/pileOfCards.go index c8b81c87..427bba47 100644 --- a/go/game/pileOfCards.go +++ b/go/game/pileOfCards.go @@ -1,8 +1,13 @@ package game +import ( + "golang.org/x/exp/slices" +) + type PileOfCards interface { Size() int IsEmpty() bool + Contains(*Card) bool Cards() []*Card AddCards(cards []*Card) AddCard(card *Card) @@ -27,6 +32,10 @@ func (poc *PileOfCardsBase) IsEmpty() bool { return poc.Size() == 0 } +func (poc *PileOfCardsBase) Contains(card *Card) bool { + return slices.Contains(poc.cards, card) +} + func (poc *PileOfCardsBase) Cards() []*Card { return poc.cards } |
