commit 4d166209bc8baa542028d996db9545b8398ae2cf Author: nyosic Date: Fri Feb 7 12:35:03 2025 +0100 1 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..67bd289 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "*.embeddedhtml": "html", + "ostream": "cpp" + } +} \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..3ae10ff --- /dev/null +++ b/main.cpp @@ -0,0 +1,135 @@ +#include +#include +#include + +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; +} diff --git a/main.exe b/main.exe new file mode 100644 index 0000000..8fde5fd Binary files /dev/null and b/main.exe differ