Wheel spin testing
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from Wheel import Wheel
|
from Wheel import Wheel
|
||||||
from random import random
|
from random import random
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
class SlotMachine():
|
class SlotMachine():
|
||||||
def __init__(self, screen_w=3, screen_h=3):
|
def __init__(self, screen_w=3, screen_h=3):
|
||||||
@@ -9,7 +10,7 @@ class SlotMachine():
|
|||||||
wheel = Wheel(size=screen_h)
|
wheel = Wheel(size=screen_h)
|
||||||
self.wheels.append(wheel)
|
self.wheels.append(wheel)
|
||||||
|
|
||||||
def spin(self, wSpins=3):
|
def spin(self, wSpins=1):
|
||||||
for _ in range(wSpins):
|
for _ in range(wSpins):
|
||||||
for wheel in self.wheels:
|
for wheel in self.wheels:
|
||||||
wheel.spin()
|
wheel.spin()
|
||||||
@@ -38,13 +39,23 @@ class SlotMachine():
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
machine = SlotMachine()
|
machine = SlotMachine()
|
||||||
|
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)
|
print(machine)
|
||||||
machine.spin(wSpins=1)
|
sleep(1)
|
||||||
print(machine)
|
|
||||||
machine.spin(wSpins=1)
|
print("Woohoo!")
|
||||||
print(machine)
|
|
||||||
machine.spin(wSpins=1)
|
|
||||||
print(machine)
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user