140 lines
5.3 KiB
Python
140 lines
5.3 KiB
Python
from upgrades import coin_multiplier, lucky_coin, flip_chance
|
|
#import menu
|
|
import random
|
|
|
|
coins_per_head = 0.5
|
|
wealth = 5000
|
|
heads_amount = 1
|
|
|
|
#Game
|
|
def coin_flip(wealth, coins_per_head, heads_amount):
|
|
while True:
|
|
result = random.randint(0, 100)
|
|
if result in range(0,base_lvl_flip_chance.chance):
|
|
print(f'Kopf ({heads_amount}x)')
|
|
heads_amount += 1 #Anzahl an hintereinander geworfenen "Köpfen"
|
|
if heads_amount >=3:
|
|
coins_per_head += base_lvl_coin_multiplier.multiplier #Coin-Boost für mehrfaches werfen von Kopf hintereinander
|
|
else:
|
|
coins_per_head = 0.5
|
|
wealth += coins_per_head
|
|
print('')
|
|
print(f'Du hast {wealth} Coins (+ {coins_per_head})')
|
|
answer = input()
|
|
try:
|
|
answer = int(answer)
|
|
if answer == 4:
|
|
homepage_upgrades(wealth)
|
|
else:
|
|
continue
|
|
except ValueError:
|
|
continue
|
|
elif result in range(base_lvl_flip_chance.chance,100):
|
|
print('Zahl')
|
|
heads_amount = 1
|
|
answer = input()
|
|
try:
|
|
answer = int(answer)
|
|
if answer == 4:
|
|
homepage_upgrades(wealth)
|
|
else:
|
|
continue
|
|
except ValueError:
|
|
continue
|
|
return result
|
|
|
|
class coin_multiplier(): #Klasse, die das Upgrade darstellt, welches die anzahl des Bonusses beim Kopfwurf veraendert
|
|
def __init__(self, multiplier:float, cost:int):
|
|
self.multiplier = multiplier
|
|
self.cost = cost
|
|
|
|
class flip_chance(): #Upgrade, welches die Chance auf kopf veraendert
|
|
def __init__(self, chance:int, cost:int):
|
|
self.chance = chance
|
|
self.cost = cost
|
|
|
|
class lucky_coin(): #Upgrade, welches festlegt wie hoch die Wahrscheinlichkeit auf einen LuckyCoin (Jackpot) ist
|
|
def __init__(self, chance:float, cost:int):
|
|
self.chance = chance
|
|
self.cost = cost
|
|
|
|
|
|
base_lvl_coin_multiplier = coin_multiplier(0.5, 10)
|
|
base_lvl_flip_chance = flip_chance(10, 1)
|
|
base_lvl_lucky_coin = lucky_coin(0.5, 10)
|
|
|
|
def lvl_up_multiplier():
|
|
lvl_up = True
|
|
|
|
if lvl_up == True:
|
|
base_lvl_coin_multiplier.cost *= 2.5
|
|
base_lvl_coin_multiplier.multiplier *= 5
|
|
#print(f' CM: {base_lvl_coin_multiplier.cost}')
|
|
print(f' Coin Multiplier liegt bei: {base_lvl_coin_multiplier.multiplier}')
|
|
|
|
def lvl_up_flip_chance():
|
|
lvl_up = True
|
|
|
|
if lvl_up == True:
|
|
base_lvl_flip_chance.cost *= 10
|
|
base_lvl_flip_chance.chance *= 2
|
|
#print(f" FC Cost: {base_lvl_flip_chance.cost}")
|
|
print(f" Flip Chance liegt bei: {base_lvl_flip_chance.chance}%")
|
|
|
|
def lvl_up_lucky_coin():
|
|
lvl_up = True
|
|
|
|
if lvl_up == True:
|
|
base_lvl_lucky_coin.cost *= 3
|
|
base_lvl_lucky_coin.chance *= 1.5
|
|
#print(f" Lucky Coin Cost: {base_lvl_lucky_coin.cost}")
|
|
print(f" Lucky Coin Chance liegt bei: {base_lvl_lucky_coin.chance}%")
|
|
|
|
def homepage_upgrades(wealth):
|
|
while True:
|
|
answer = input(f' Flip Chance [{base_lvl_flip_chance.chance}% > {base_lvl_flip_chance.chance*2}%] (Preis: {base_lvl_flip_chance.cost} Coins): [1]\n Lucky Coin [{base_lvl_lucky_coin.chance}% > {base_lvl_lucky_coin.chance*2}] (Preis: {base_lvl_lucky_coin.cost} Coins): [2]\n Multiplier [+{base_lvl_coin_multiplier.multiplier} Coins > {base_lvl_coin_multiplier.multiplier*5} Coins] (Preis: {base_lvl_coin_multiplier.cost} Coins): [3]\n Zum Game: [4]')
|
|
try:
|
|
answer = int(answer)
|
|
if answer == 1:
|
|
if wealth >= base_lvl_flip_chance.cost:
|
|
lvl_up_flip_chance()
|
|
wealth -= base_lvl_flip_chance.cost
|
|
print(f' Erfolgreich geupgradet. Du hast noch {wealth} Coins')
|
|
|
|
else:
|
|
print('Du bist zu arm')
|
|
|
|
elif answer == 2:
|
|
if wealth >= base_lvl_lucky_coin.cost:
|
|
lvl_up_lucky_coin()
|
|
wealth -= base_lvl_lucky_coin.cost
|
|
print(f' Erfolgreich geupgradet. Du hast noch {wealth} Coins')
|
|
else:
|
|
print('Du bist zu arm')
|
|
|
|
elif answer == 3:
|
|
if wealth >= base_lvl_coin_multiplier.cost:
|
|
lvl_up_multiplier()
|
|
wealth -= base_lvl_coin_multiplier.cost
|
|
print(f' Erfolgreich geupgradet. Du hast noch {wealth} Coins')
|
|
else:
|
|
print('Du bist zu arm')
|
|
elif answer == 4:
|
|
coin_flip(wealth, coins_per_head, heads_amount)
|
|
|
|
elif answer not in (1, 2, 3, 4):
|
|
print('Bitte 1, 2, 3 oder 4!')
|
|
|
|
except ValueError:
|
|
print('Nur Zahlen')
|
|
input()
|
|
|
|
def check_lucky_coin(result, wealth):
|
|
if result < base_lvl_lucky_coin.chance or result == base_lvl_lucky_coin.chance:
|
|
print('Herzlichen Glueckwunsch! Du hast den Lucky Coin bekommen')
|
|
wealth *= 1.5
|
|
return wealth
|
|
|
|
|
|
result = coin_flip(wealth, coins_per_head, heads_amount)
|
|
wealth = check_lucky_coin(result, wealth) |