-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslot.py
105 lines (92 loc) · 2.97 KB
/
slot.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import random
from collections import Counter
from player import Player
import input
from result import Result
import time
import save
prizelist = ['🍒','🍑','🍋','💎','💲']
values = ['','','']
class Slot():
roll1 = None
roll2 = None
roll3 = None
prize = 0
prizelist = ['🍒','🍑','🍋','💎','💲']
values = values
def __init__ (self, roll1, roll2, roll3, prize, prizelist, values):
self.roll1 = roll1
self.roll2 = roll2
self.roll3 = roll3
self.prize = prize
self.prizelist = prizelist
self.values = values
def roll(self,newPlayer):
newPlayer.money -= 5
self.roll1 = random.choice(self.prizelist)
self.roll2 = random.choice(self.prizelist)
self.roll3 = random.choice(self.prizelist)
self.values = [self.roll1,self.roll2,self.roll3]
print(self.values)
time.sleep(1)
result = self.checkWin()
prize = self.checkPrize(result)
newPlayer.money += prize
save.save(newPlayer)
self.again(newPlayer)
def checkWin(self) -> Result:
#win_or_loss, winning_symbol, winning_count
counts = Counter(self.values).most_common(1)[0]
if counts [1] > 1:
result = Result(
True,
counts[0],
counts[1]
)
print("Congrats, you win!")
elif "💲" in self.values:
result = Result(True, "💲", 1)
print("Congrats, you win!")
elif "💎" in self.values:
result = Result(True, "💎", 1)
print("Congrats, you win!")
else:
print("You lose! :(")
result = Result(False,"",1)
return result
def checkPrize(self, result: Result) -> int:
if result.win:
match result.symbol:
case '🍑':
return 2 * (result.count - 1)
case '🍋':
return 4 * (result.count - 1)
case '🍒':
return 10 * (result.count - 1)
case '💎':
if result.count != 1:
return 30 * (result.count - 1)
else:
return 5
case '💲':
if result.count != 1:
return 75 * (result.count - 1)
else:
return 10
case _:
return 0
return 0
def again(self,newPlayer):
x = 1
newInput = input.Input(0)
time.sleep(1.5)
print("You now have " + str(newPlayer.money) + "$.")
time.sleep(1.5)
print("Do you want to play again?\ny/n")
while x == 1:
newInput.inputYN()
if newInput.input == True:
self.roll(newPlayer)
x += 1
elif newInput.input == False:
exit()