-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.py
More file actions
24 lines (19 loc) · 775 Bytes
/
core.py
File metadata and controls
24 lines (19 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import random
class SlotMachine:
def __init__(self, reels=3, paylines=1, symbols=['🍒', '🍊', '🍋', '🍇', '🍉']):
self.reels = reels
self.paylines = paylines
self.symbols = symbols
self.payout_table = {'🍒': 5, '🍊': 3, '🍋': 2, '🍇': 4, '🍉': 10}
def spin(self):
return [random.choice(self.symbols) for _ in range(self.reels)]
def check_payout(self, spin_result):
payout = 0
for symbol in spin_result:
payout += self.payout_table.get(symbol, 0)
return payout
def display(self, spin_result):
print(f"Spin result: {' | '.join(spin_result)}")
payout = self.check_payout(spin_result)
print(f"Payout: {payout}")
return payout