NyscoCasino_GAME/main.cpp

136 lines
3.9 KiB
C++
Raw Normal View History

2025-02-07 12:35:03 +01:00
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int balance = 0;
void coinflip() {
srand(time(0)); // Seed the random number generator
int bet_amount;
char user_choice;
cout << "Enter the amount of money you want to bet on the coin flip: ";
cin >> bet_amount;
// Check if the user has enough balance
if (bet_amount > balance) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl;
return;
}
// Deduct the bet amount from the balance
balance -= bet_amount;
cout << "Choose your side: (H) for Heads or (T) for Tails: ";
cin >> user_choice;
// Validate user input
if (user_choice != 'H' && user_choice != 'h' && user_choice != 'T' && user_choice != 't') {
cout << "Invalid choice. Please enter either H for Heads or T for Tails." << endl;
balance += bet_amount; // Return the bet amount if invalid input
return;
}
// Generate a random result: 0 for Heads, 1 for Tails
int flip_result = rand() % 2;
// Show the result
cout << "The coin is flipping..." << endl;
// Wait a moment to simulate flipping
system("pause");
if (flip_result == 0) {
cout << "The result is Heads!" << endl;
} else {
cout << "The result is Tails!" << endl;
}
// Check if the user won or lost
if ((user_choice == 'H' || user_choice == 'h') && flip_result == 0) {
cout << "Congratulations! You won! You get double the bet amount." << endl;
balance += 2 * bet_amount;
} else if ((user_choice == 'T' || user_choice == 't') && flip_result == 1) {
cout << "Congratulations! You won! You get double the bet amount." << endl;
balance += 2 * bet_amount;
} else {
cout << "Sorry! You lost the bet. Better luck next time!" << endl;
}
cout << "Your new balance is: " << balance << " NyscoCoins" << endl;
}
void slots() {
// Slots game logic here
}
void deposit() {
int deposit_amount;
cout << "Enter the amount of money you want to deposit: ";
cin >> deposit_amount;
balance += deposit_amount;
system("cls");
cout << "Deposit successful! Your new balance is: " << balance << " NyscoCoins" << endl;
}
int main() {
char game_choice;
do {
cout << "Your current balance: " << balance << " NyscoCoins" << endl;
cout << R"(
_ __ ______ _
/ | / /_ ________________ / ____/___ ______(_)___ ____
/ |/ / / / / ___/ ___/ __ \ / / / __ `/ ___/ / __ \/ __ \
/ /| / /_/ (__ ) /__/ /_/ / / /___/ /_/ (__ ) / / / / /_/ /
/_/ |_/\__, /____/\___/\____/ \____/\__,_/____/_/_/ /_/\____/
/____/
--------------------------------------------------------------------------
)" << endl;
cout << "CHOOSE THE GAME: " << endl;
cout << "(C) - Coinflip" << endl;
cout << "(S) - Slots" << endl;
cout << "(D) - Deposit money" << endl;
cout << endl;
cout << "(Q) - I Don't have more money I'm quitting" << endl;
cout << endl;
cout << "Enter your choice: ";
cin >> game_choice;
switch (game_choice) {
case 'C':
case 'c':
system("cls");
coinflip();
break;
case 'S':
case 's':
system("cls");
slots();
break;
case 'D':
case 'd':
system("cls");
deposit();
break;
case 'Q':
case 'q':
cout << "Thanks for playing!" << endl;
break;
default:
cout << "Invalid choice. Please try again." << endl;
break;
}
} while (game_choice != 'Q' && game_choice != 'q');
return 0;
}