-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_brainTest.py
83 lines (73 loc) · 2.12 KB
/
test_brainTest.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from player import Player
from deck import Deck
from card import Card
from brainTest import BrainTest
print "Test basic player"
b1 = BrainTest()
p1 = Player(b1)
print "Info of p1:"
print p1
p1.setID(3)
p1.setName("Shawn")
print "Info of p1:"
print p1
d1 = Deck()
print "Check if Hands of p1 is empty:"
if p1.handIsEmpty():
print "Yes!"
else:
print "No!"
print "Hands of p1 at the beginning"
p1.displayHands()
cd1 = d1.popCard()
p1.drawCard(cd1)
cd1 = d1.popCard()
p1.drawCard(cd1)
cd1 = d1.popCard()
p1.drawCard(cd1)
cd1 = d1.popCard()
p1.drawCard(cd1)
print "Hands of p1 after drawing for 4 times"
p1.displayHands()
print "\n\n"
################################################################################
#test declareTrump()
print "Test declareTrump()"
cdOnDesk = [[],[],[]]
declareCards = p1.declareTrump(cdOnDesk)
if declareCards == False:#not declared
print str(p1) + " does not want to declare trump."
else:#delcare trump
print str(p1) + " wants to declare trump using these cards:"
for item in declareCards:
print item
print "\n\n"
################################################################################
#test replaceBottom()
print "Test replaceBottom()"
print "Old bottom:"
for item in d1.getBottom():
print item
newBottom = p1.replaceBottom(d1.getBottom())
print "Try to replace the bottom with these cards:"
for item in newBottom:
print item
print "deck.bottom should not have been changed at this stage since we need Game to call deck.changeBottom() to Actually change deck.bottom"
print "Let's check if deck.bottom is still the old one:"
for item in d1.getBottom():
print item
print "\n\n"
################################################################################
#test declareToPlayCards()
print "Test declareToPlayCards()"
cardToBePlayed1 = p1.declareToPlayCards(cdOnDesk)
print str(p1) + " tried to play: "
for item in cardToBePlayed1:
print item
#check if cardToBePlayed1 obey the rules
#if it obey the rules:
p1.playCards(cardToBePlayed1)
#otherwise do nothing or perhaps call p1.declareToPlayCards() again
print "Hands of p1 after play some cards"
p1.displayHands()
print "\n\n"