mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-27 13:42:28 -06:00
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
|
import random
|
||
|
import PlayingCardGlobals
|
||
|
from toontown.minigame.PlayingCard import PlayingCardBase
|
||
|
|
||
|
class PlayingCardDeck:
|
||
|
|
||
|
def __init__(self):
|
||
|
self.shuffle()
|
||
|
|
||
|
def shuffle(self):
|
||
|
self.cards = range(0, PlayingCardGlobals.MaxSuit * PlayingCardGlobals.MaxRank)
|
||
|
random.shuffle(self.cards)
|
||
|
|
||
|
def shuffleWithSeed(self, seed):
|
||
|
generator = random.Random()
|
||
|
generator.seed(seed)
|
||
|
self.cards = range(0, PlayingCardGlobals.MaxSuit * PlayingCardGlobals.MaxRank)
|
||
|
generator.shuffle(self.cards)
|
||
|
|
||
|
def dealCard(self):
|
||
|
return self.cards.pop(0)
|
||
|
|
||
|
def dealCards(self, num):
|
||
|
cardList = []
|
||
|
for i in xrange(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
|