-
Notifications
You must be signed in to change notification settings - Fork 1
/
Deck.py
42 lines (34 loc) · 1.15 KB
/
Deck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import random
from Cards import Cards
class Deck():
Rawdeck = []
types = ["Spade", "Heart", "Club", "Diamond"]
def __init__(self):
self.Rawdeck = []
def initdeck(self):
n = 1
while n<53:
Tempnum = random.randint(1, 13)
Temptype = random.randint(0, 3)
Temp = Cards(Tempnum, self.types[Temptype])
Existence = False
i = 0
while i<len(self.Rawdeck):
if self.Rawdeck[i].getnumber() is Tempnum and self.Rawdeck[i].gettype() is self.types[Temptype]:
Existence = True
i = i + 1
if Existence == False:
self.Rawdeck.append(Temp)
n = n + 1
def Display(self):
iterator = iter(self.Rawdeck)
haselement = False
while not haselement:
try:
Temp = next(iterator)
print(str(Temp.number) + Temp.type)
except StopIteration:
haselement = True
print("no more element")
def Drawcard(self):
return self.Rawdeck.pop()