Added basic wheel functionality
This commit is contained in:
6
src/py/slots/Slots.py
Normal file
6
src/py/slots/Slots.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from Wheel import Wheel
|
||||
|
||||
class SlotMachine():
|
||||
def __init__(self):
|
||||
jackpot = 0
|
||||
wheel = Wheel()
|
||||
22
src/py/slots/Wheel.py
Normal file
22
src/py/slots/Wheel.py
Normal file
@@ -0,0 +1,22 @@
|
||||
class Wheel():
|
||||
def __init__(self, size=3):
|
||||
self.size=size
|
||||
self.icons = list(range(size))
|
||||
|
||||
def roll(self, offset=1):
|
||||
new_icons = list(range(self.size))
|
||||
for i, icon in enumerate(self.icons):
|
||||
new_icons[(i + offset) % len(new_icons)] = icon
|
||||
|
||||
self.icons = new_icons
|
||||
|
||||
|
||||
def main():
|
||||
wheel = Wheel(size=10)
|
||||
print(wheel.icons)
|
||||
wheel.roll(offset=3)
|
||||
print(wheel.icons)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user