You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class CrashGameEmulator:
def init(self, initial_balance):
self.balance = initial_balance
def simulate_crash(self):
"""Simulates the crash multiplier"""
crash_multiplier = round(random.uniform(1.0, 10.0), 2)
return crash_multiplier
def play_round(self, bet_amount):
"""Plays a single round of the crash game"""
if bet_amount > self.balance:
print("Insufficient balance!")
return
print("\nStarting game... 🚀")
crash_multiplier = self.simulate_crash()
time.sleep(1) # Simulate time for crash buildup
print(f"Crash multiplier: {crash_multiplier}x")
cash_out_multiplier = float(input("Enter your cash-out multiplier (or 0 to risk it all): "))
if cash_out_multiplier > crash_multiplier or cash_out_multiplier <= 0:
print("Oops! The game crashed before you could cash out.")
self.balance -= bet_amount
else:
winnings = bet_amount * cash_out_multiplier
self.balance += winnings - bet_amount
print(f"You cashed out successfully and won: ${winnings - bet_amount:.2f}")
print(f"New Balance: ${self.balance:.2f}")
return crash_multiplier
def main():
print("Welcome to the Crash Game Emulator! 🎮")
initial_balance = float(input("Enter your initial balance: "))
emulator = CrashGameEmulator(initial_balance)
while True:
print(f"\nCurrent Balance: ${emulator.balance:.2f}")
bet = float(input("Enter your bet amount (or 0 to quit): "))
if bet == 0:
print("Thanks for playing! Goodbye!")
break
emulator.play_round(bet)
No description provided.
The text was updated successfully, but these errors were encountered: