diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-08 12:01:58 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:48 +0100 |
| commit | 7c288f65c4e821d9bbb9b8d880f1378d0eaea816 (patch) | |
| tree | de9f4b4b2bd6899104f7773be352bd0459e5716a | |
| parent | d58b358a170306694b9f6da004cd6f474a0314a8 (diff) | |
| download | muhqs-game-7c288f65c4e821d9bbb9b8d880f1378d0eaea816.tar.gz muhqs-game-7c288f65c4e821d9bbb9b8d880f1378d0eaea816.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 } |
