Casinx/casinx.py
2023-11-29 19:13:48 +01:00

45 lines
No EOL
1.2 KiB
Python

#!/usr/bin/python3
from random import randint
from time import sleep
from os import get_terminal_size
x,y = get_terminal_size().columns,get_terminal_size().lines
## variablen
zeichen = "%-+#$~"
slots = [["a","b","c"], #slot 1
["2","#","2"], #slot 2
["3","3","3"]] #slot 3
## funtionen
def pslots():
tren = "+-----------+"
halb = int(x/2)-5
space = "-"*halb
pr = f"{space}| "
for b in range(0,3):
for a in range(0,3):
pr += slots[a][b]+" "
pr += f"|\n{space}| "
print(space+tren)
print(pr[:-(space[:-3])])
print(space+tren)
def roll_slot(slots,slot=int,new_zeichen=str):
back = slots[slot]
back[2] = back[1]
back[1] = back[0]
back[0] = new_zeichen
slots[slot] = back
return slots
def roll_all():
brems_speed = 1
speed = 0.001
while not brems_speed <= speed:
sleep(speed)
roll_slot(slots,0,zeichen[randint(0,len(zeichen)-1)])
roll_slot(slots,1,zeichen[randint(0,len(zeichen)-1)])
roll_slot(slots,2,zeichen[randint(0,len(zeichen)-1)])
pslots()
print(speed,brems_speed)
speed += 0.06
##programmschleife
roll_all()