2023-11-29 17:21:27 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
from random import randint
|
|
|
|
from time import sleep
|
2023-11-29 20:14:13 +01:00
|
|
|
import os
|
|
|
|
x,y = os.get_terminal_size().columns,os.get_terminal_size().lines
|
2023-11-29 17:21:27 +01:00
|
|
|
## variablen
|
2023-11-29 20:14:13 +01:00
|
|
|
start_coins = 20
|
2023-11-29 17:21:27 +01:00
|
|
|
zeichen = "%-+#$~"
|
|
|
|
slots = [["a","b","c"], #slot 1
|
|
|
|
["2","#","2"], #slot 2
|
|
|
|
["3","3","3"]] #slot 3
|
|
|
|
|
|
|
|
## funtionen
|
2023-11-29 20:14:13 +01:00
|
|
|
def clear():
|
|
|
|
if os.name == "nt":
|
|
|
|
os.system("cls")
|
|
|
|
else:
|
|
|
|
os.system("clear")
|
|
|
|
|
|
|
|
def prints():
|
2023-11-29 17:21:27 +01:00
|
|
|
tren = "+-----------+"
|
2023-11-29 19:13:48 +01:00
|
|
|
halb = int(x/2)-5
|
2023-11-29 20:14:13 +01:00
|
|
|
space = str(" "*halb)
|
2023-11-29 19:13:48 +01:00
|
|
|
pr = f"{space}| "
|
2023-11-29 20:14:13 +01:00
|
|
|
for a in range(0,len(slots)):
|
|
|
|
for b in range(0,len(slots[0])):
|
|
|
|
pr += slots[b][a]+" "
|
2023-11-29 19:13:48 +01:00
|
|
|
pr += f"|\n{space}| "
|
|
|
|
print(space+tren)
|
2023-11-29 20:14:13 +01:00
|
|
|
print(pr[:-halb-4])
|
2023-11-29 19:13:48 +01:00
|
|
|
print(space+tren)
|
2023-11-29 17:21:27 +01:00
|
|
|
|
|
|
|
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
|
2023-11-29 20:14:13 +01:00
|
|
|
def printl():
|
|
|
|
print(" "*(int(x/2)-8),"+-+-+ Casinx +-+-+\n")
|
|
|
|
|
2023-11-29 17:21:27 +01:00
|
|
|
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)])
|
2023-11-29 20:14:13 +01:00
|
|
|
clear()
|
|
|
|
printl()
|
|
|
|
prints()
|
2023-11-29 17:21:27 +01:00
|
|
|
speed += 0.06
|
2023-11-29 20:14:13 +01:00
|
|
|
def blink(z=str,z2=str,time=str):
|
|
|
|
def b(z,z2):
|
|
|
|
for a in range(len(slots)):
|
|
|
|
for b in range(len(slots[0])):
|
|
|
|
if slots[a][b] == z:
|
|
|
|
slots[a][b] = z2
|
|
|
|
for a in range(0,time):
|
|
|
|
b(z,z2)
|
|
|
|
prints()
|
|
|
|
sleep(0.2)
|
|
|
|
clear()
|
|
|
|
b(z2,z)
|
|
|
|
prints()
|
|
|
|
sleep(0.2)
|
|
|
|
clear()
|
|
|
|
|
|
|
|
|
2023-11-29 17:21:27 +01:00
|
|
|
##programmschleife
|
2023-11-29 20:14:13 +01:00
|
|
|
|
|
|
|
roll_all()
|
|
|
|
blink("-"," ",10)
|