Wheel spin testing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from Wheel import Wheel
|
||||
from random import random
|
||||
from time import sleep
|
||||
|
||||
class SlotMachine():
|
||||
def __init__(self, screen_w=3, screen_h=3):
|
||||
@@ -9,7 +10,7 @@ class SlotMachine():
|
||||
wheel = Wheel(size=screen_h)
|
||||
self.wheels.append(wheel)
|
||||
|
||||
def spin(self, wSpins=3):
|
||||
def spin(self, wSpins=1):
|
||||
for _ in range(wSpins):
|
||||
for wheel in self.wheels:
|
||||
wheel.spin()
|
||||
@@ -32,19 +33,29 @@ class SlotMachine():
|
||||
for icon in row:
|
||||
string += str(icon) + " "
|
||||
string += "\n"
|
||||
|
||||
|
||||
return string
|
||||
|
||||
|
||||
def main():
|
||||
machine = SlotMachine()
|
||||
print(machine)
|
||||
machine.spin(wSpins=1)
|
||||
print(machine)
|
||||
machine.spin(wSpins=1)
|
||||
print(machine)
|
||||
machine.spin(wSpins=1)
|
||||
print(machine)
|
||||
win = False
|
||||
result = []
|
||||
machine.spin(wSpins=3)
|
||||
while win == False:
|
||||
machine.spin()
|
||||
result = machine.wheels
|
||||
first_icon = result[0].icons[1]
|
||||
|
||||
if all(wheel.icons[1] == first_icon for wheel in result):
|
||||
|
||||
win = True
|
||||
|
||||
print(machine)
|
||||
sleep(1)
|
||||
|
||||
print("Woohoo!")
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user