/
build_deck.py
53 lines (47 loc) · 1.46 KB
/
build_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
43
44
45
46
47
48
49
50
51
52
import random
import time
from card import card
class BuildDeck(object):
"""docstring for BuildDeck"""
def __init__(self, deck):
super(BuildDeck, self).__init__()
self.cards = []
self.cards.append(card(random.randint(0, 19)))
self.cards.append(card(random.randint(0, 19)))
self.cards.append(card(random.randint(0, 19)))
self.cards[0].position = (0, 133)
self.cards[1].position = (300, 133)
self.cards[2].position = (600, 133)
self.cards[0].onScreen = True
self.cards[1].onScreen = True
self.cards[2].onScreen = True
self.deck = deck
random.seed(time.time)
def draw(self, surface):
self.cards[0].draw(surface)
self.cards[1].draw(surface)
self.cards[2].draw(surface)
#happens every time you select a card
def getNewCards(self):
self.cards[0] = card(random.randint(0, 19))
self.cards[1] = card(random.randint(0, 19))
self.cards[2] = card(random.randint(0, 19))
self.cards[0].position = (0, 133)
self.cards[1].position = (300, 133)
self.cards[2].position = (600, 133)
self.cards[0].onScreen = True
self.cards[1].onScreen = True
self.cards[2].onScreen = True
def click(self, pos):
if(self.cards[0].click_on(pos[0], pos[1])):
# todo
self.deck.add_card(self.cards[0])
self.getNewCards()
elif(self.cards[1].click_on(pos[0], pos[1])):
# todo
self.deck.add_card(self.cards[1])
self.getNewCards()
elif(self.cards[2].click_on(pos[0], pos[1])):
# todo
self.deck.add_card(self.cards[2])
self.getNewCards()