diff options
Diffstat (limited to 'go/game/pileOfCards.go')
| -rw-r--r-- | go/game/pileOfCards.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/go/game/pileOfCards.go b/go/game/pileOfCards.go index 5edae617..0ad0f157 100644 --- a/go/game/pileOfCards.go +++ b/go/game/pileOfCards.go @@ -2,6 +2,7 @@ package game import ( "fmt" + "math/rand" "golang.org/x/exp/slices" ) @@ -96,3 +97,12 @@ func (poc *PileOfCardsBase) ToList() (list string) { return list[:len(list)-1] } + +func NewRandomPackFromPool(pool PileOfCards, packSize int) PileOfCards { + pack := NewPileOfCards() + for _ = range packSize { + card := pool.Cards()[rand.Intn(len(pool.Cards())-1)] + pool.MoveCard(card, pack) + } + return pack +} |
