-
Notifications
You must be signed in to change notification settings - Fork 0
/
craps.py
70 lines (57 loc) · 1.74 KB
/
craps.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
from random import randint
global pointOn,point
comeOnBet = 0
playerBank = 1000
playing = 'Y'
#roll while point is set
def rollwhilepoint():
global pointOn,point,comeOnBet,playerBank
while pointOn:
v=roll()
if v == point:
print "You win!"
playerBank += (comeOnBet*2)
print "Your balance is",playerBank
pointOn = False
elif v == 7:
print "You lose! \n Your balance is",playerBank
pointOn = False
#initial roll
def roll():
raw_input("Press any key to roll")
#roll dice
d1=randint(1,6)
d2=randint(1,6)
v=d1+d2
print "You rolled a " , v
return v
def gameplay():
global pointOn, point, playerBank, playing, comeOnBet
pointOn=False
point=0
playing = raw_input("Are you ready? Type Y to make a bet and play some Craps" )
while playing == 'Y':
while playerBank > 0:
print "\nLet's play! You have",playerBank,"to bet with!"
comeOnBet = int(raw_input("How much is your come on bet?" ))
while comeOnBet < 1:
comeOnBet = int(raw_input("How much is your come on bet?" ))
playerBank -= comeOnBet
v = roll()
if v == 7 or v == 11:
print "You won on the come out!"
playerBank += (comeOnBet*2)
elif v == 2 or v == 3 or v == 12:
print "You lost on the come out!"
else:
print "The point is set to", v
point = v
pointOn = True
rollwhilepoint();
print "You have overleveraged and you are poor now... Goodbye"
playing = 'N'
#
#
# while playing == 'Y':
gameplay();
print "Thanks for playing!"