2019-11-02 17:27:54 -05:00
|
|
|
import random
|
2019-12-30 00:07:56 -06:00
|
|
|
from . import PlayingCardGlobals
|
2019-11-02 17:27:54 -05:00
|
|
|
from toontown.minigame.PlayingCard import PlayingCardBase
|
|
|
|
|
|
|
|
class PlayingCardDeck:
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.shuffle()
|
|
|
|
|
|
|
|
def shuffle(self):
|
2019-12-30 00:07:56 -06:00
|
|
|
self.cards = list(range(0, PlayingCardGlobals.MaxSuit * PlayingCardGlobals.MaxRank))
|
2019-11-02 17:27:54 -05:00
|
|
|
random.shuffle(self.cards)
|
|
|
|
|
|
|
|
def shuffleWithSeed(self, seed):
|
|
|
|
generator = random.Random()
|
|
|
|
generator.seed(seed)
|
2019-12-30 00:07:56 -06:00
|
|
|
self.cards = list(range(0, PlayingCardGlobals.MaxSuit * PlayingCardGlobals.MaxRank))
|
2019-11-02 17:27:54 -05:00
|
|
|
generator.shuffle(self.cards)
|
|
|
|
|
|
|
|
def dealCard(self):
|
|
|
|
return self.cards.pop(0)
|
|
|
|
|
|
|
|
def dealCards(self, num):
|
|
|
|
cardList = []
|
|
|
|
for i in range(num):
|
|
|
|
cardList.append(self.cards.pop(0))
|
|
|
|
|
|
|
|
return cardList
|
|
|
|
|
|
|
|
def count(self):
|
|
|
|
return len(self.cards)
|
|
|
|
|
|
|
|
def removeRanksAbove(self, maxRankInDeck):
|
|
|
|
done = False
|
|
|
|
while not done:
|
|
|
|
removedOne = False
|
|
|
|
for cardValue in self.cards:
|
|
|
|
tempCard = PlayingCardBase(cardValue)
|
|
|
|
if tempCard.rank > maxRankInDeck:
|
|
|
|
self.cards.remove(cardValue)
|
|
|
|
removedOne = True
|
|
|
|
|
|
|
|
if not removedOne:
|
|
|
|
done = True
|