aboutsummaryrefslogtreecommitdiff
path: root/go/game/deck.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/deck.go')
-rw-r--r--go/game/deck.go22
1 files changed, 5 insertions, 17 deletions
diff --git a/go/game/deck.go b/go/game/deck.go
index f4290322..58a08985 100644
--- a/go/game/deck.go
+++ b/go/game/deck.go
@@ -9,36 +9,24 @@ import (
)
type Deck struct {
- Cards []*Card
+ PileOfCardsBase
}
func NewDeck() *Deck {
- d := Deck{[]*Card{}}
+ d := Deck{PileOfCardsBase{[]*Card{}}}
return &d
}
-func (d *Deck) AddCards(cards []*Card) {
- d.Cards = append(d.Cards, cards...)
-}
-
-func (d *Deck) AddCard(card *Card) {
- d.Cards = append(d.Cards, card)
-}
-
-func (d *Deck) Size() int {
- return len(d.Cards)
-}
-
func (d *Deck) Shuffle() {
rand.Seed(time.Now().UnixNano())
rand.Shuffle(d.Size(), func(i, j int) {
- d.Cards[i], d.Cards[j] = d.Cards[j], d.Cards[i]
+ d.cards[i], d.cards[j] = d.cards[j], d.cards[i]
})
}
func (d *Deck) Draw(amount int) []*Card {
- drawn := d.Cards[-amount:]
- d.Cards = d.Cards[:amount]
+ drawn := d.cards[0:amount]
+ d.cards = d.cards[:amount]
return drawn
}