Casinx/casinx.py

75 lines
1.7 KiB
Python
Raw Permalink Normal View History

2023-11-29 17:21:27 +01:00
#!/usr/bin/python3
from random import randint
from time import sleep
import os
x,y = os.get_terminal_size().columns,os.get_terminal_size().lines
2023-11-29 17:21:27 +01:00
## variablen
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
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
space = str(" "*halb)
2023-11-29 19:13:48 +01:00
pr = f"{space}| "
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)
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
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)])
clear()
printl()
prints()
2023-11-29 17:21:27 +01:00
speed += 0.06
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
roll_all()
blink("-"," ",10)