-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcliview.py
48 lines (39 loc) · 1.44 KB
/
cliview.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
from pyatzee_engine import engine
import hand
class cliview(object):
def __init__(self):
print "Welcome to Pyatzee!!\n"
self.engine = engine(self)
def show_scoreboard(self,scoreengine):
#show the scoreboard from the engine
total = 0
for type in scoreengine.get_scoreboard():
print "%s: %s" % (type[0],type[1])
total += type[2]
print "TOTAL: %d" % total
def show_hand(self,hand):
#show the hand you have, choose what to hold
for i in range(1,6):
if hand.dice[i-1].held: isheld = "*"
else: isheld = ""
print "(%d): %d %s" % (i,hand.dice[i-1].value,isheld)
def get_input(self, hand):
i = raw_input("select holds> ")
hold_vals = i.split(" ")
hold_vals = map(int,hold_vals)
hand.unhold_all()
for val in hold_vals:
hand.dice[val - 1].held = True
def show_potential_points(self, hand, scoreengine):
#show the potential point breakdown for this hand
possibles = scoreengine.get_possible(hand)
print "Possible point vals:\n-------------"
pairs = {}
i = 1
for st in possibles:
print "(%d) %s: %d" % (i,st.title,st.score(hand))
pairs[i] = st
i += 1
i = raw_input("select to use> ")
st = pairs[int(i)]
st.use(hand)