NyscoCasino_GAME/main.cpp
2025-02-08 00:55:04 +01:00

424 lines
12 KiB
C++

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <unistd.h>
using namespace std;
char end_choice;
int balance = 0;
int bank_balance = 10000;
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;
sleep(3);
}
// 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
coinflip();
}
// 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
sleep(3);
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) {
system("clear");
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) {
system("clear");
cout << "Congratulations! You won! You get double the bet amount." << endl;
balance += 2 * bet_amount;
}
else {
system("clear");
cout << "Sorry! You lost the bet. Better luck next time!" << endl;
}
cout << "Your new balance is: " << balance << " NyscoCoins" << endl;
cout << "Play again? (Y/N): ";
cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') {
system("clear");
coinflip();
}
else {
system("clear");
}
}
void slots() {
srand(time(0));
int bet_amount;
char end_choice;
cout << "Enter the amount of money you want to bet on slots: ";
cin >> bet_amount;
if (bet_amount > balance) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl;
sleep(3);
}
balance -= bet_amount;
cout << "Spinning the slots..." << endl;
sleep(2);
int slot1 = rand() % 5 + 1;
int slot2 = rand() % 5 + 1;
int slot3 = rand() % 5 + 1;
cout << "| " << slot1 << " | " << slot2 << " | " << slot3 << " |" << endl;
if (slot1 == slot2 && slot2 == slot3) {
cout << "JACKPOT! You won triple your bet amount!" << endl;
balance += 3 * bet_amount;
}
else if (slot1 == slot2 || slot2 == slot3 || slot1 == slot3) {
cout << "Nice! You won double your bet amount!" << endl;
balance += 2 * bet_amount;
}
else {
cout << "You lost! Better luck next time!" << endl;
}
cout << "Your new balance is: " << balance << " NyscoCoins" << endl;
cout << "Play again? (Y/N): ";
cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') {
system("clear");
slots();
}
else {
system("clear");
}
}
void blackjack() {
srand(time(0));
int playerCard1 = rand() % 11 + 1;
int playerCard2 = rand() % 11 + 1;
int dealerCard1 = rand() % 11 + 1;
int dealerCard2 = rand() % 11 + 1;
int playerTotal = playerCard1 + playerCard2;
int dealerTotal = dealerCard1 + dealerCard2;
int bet_amount;
char end_choice;
cout << "Your cards: " << playerCard1 << " and " << playerCard2 << " (Total: " << playerTotal << ")" << endl;
cout << "Dealer's visible card: " << dealerCard1 << endl;
cout << "Enter your bet amount: ";
cin >> bet_amount;
if (bet_amount > balance) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl;
sleep(3);
}
balance -= bet_amount;
char choice;
do {
cout << "Do you want to hit (H) or stand (S)? ";
cin >> choice;
if (choice == 'H' || choice == 'h') {
int newCard = rand() % 11 + 1;
playerTotal += newCard;
cout << "You drew a " << newCard << ". Your total is now " << playerTotal << "." << endl;
if (playerTotal > 21) {
cout << "You bust! Dealer wins." << endl;
}
}
}
while (choice == 'H' || choice == 'h');
cout << "Dealer's turn. Dealer's total is " << dealerTotal << "." << endl;
while (dealerTotal < 17) {
int newCard = rand() % 11 + 1;
dealerTotal += newCard;
cout << "Dealer drew a " << newCard << ". Dealer's total is now " << dealerTotal << "." << endl;
}
if (dealerTotal > 21 || playerTotal > dealerTotal) {
cout << "You win! You gain " << bet_amount << " NyscoCoins." << endl;
balance += 2 * bet_amount; // Win pays 2:1
}
else if (playerTotal < dealerTotal) {
cout << "Dealer wins! You lose your bet." << endl;
}
else {
cout << "It's a tie! Your bet is returned." << endl;
balance += bet_amount; // Return bet
}
cout << "Your new balance is: " << balance << " NyscoCoins" << endl;
cout << "Play again? (Y/N): ";
cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') {
system("clear");
blackjack();
}
else {
system("clear");
}
}
void roulette() {
cout << "Roulette game logic coming soon!" << endl;
}
void diceRoll() {
srand(time(0));
int bet_amount, outcome;
char end_choice;
cout << "Enter the amount of money you want to bet on dice roll: ";
cin >> bet_amount;
cout << "Guess the outcome: ";
cin >> outcome;
if (bet_amount > balance) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl;
sleep(3);
diceRoll();
}
if (outcome > 12) {
cout << "There are only two dices max number is 12" << endl;
sleep(3);
diceRoll();
}
balance -= bet_amount;
cout << "Rolling the dice..." << endl;
sleep(2);
int dice1 = rand() % 6 + 1;
int dice2 = rand() % 6 + 1;
int total = dice1 + dice2;
cout << "You rolled: " << dice1 << " and " << dice2 << " (Total: " << total << ")" << endl;
if (total == outcome) {
cout << "Congratulations! You won double your bet amount!" << endl;
balance += 2 * bet_amount;
}
else {
cout << "You lost! Better luck next time!" << endl;
}
cout << "Your new balance is: " << balance << " NyscoCoins" << endl;
cout << "Play again? (Y/N): ";
cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') {
system("clear");
diceRoll();
}
else {
system("clear");
}
}
void higherOrLower() {
cout << "Higher or Lower game logic coming soon!" << endl;
}
void deposit() {
int deposit_amount;
cout << "Enter the amount of money you want to deposit: ";
cin >> deposit_amount;
if (bank_balance >= deposit_amount) {
balance += deposit_amount;
bank_balance -= deposit_amount;
system("clear");
cout << "Deposit successful! Your new balance is: " << balance << " NyscoCoins"<< endl;
sleep(3);
system("clear");
}
else {
system("clear");
cout << "You don't have enough money in your bank account!" << endl;
sleep(3);
system("clear");
}
}
void withdraw() {
int withdraw_amount;
cout << "Enter the amount of money you want to deposit: ";
cin >> withdraw_amount;
if (balance >= withdraw_amount) {
balance -= withdraw_amount;
bank_balance += withdraw_amount;
system("clear");
cout << "Deposit successful! Your new balance is: " << balance << " NyscoCoins" << endl;
sleep(3);
system("clear");
}
else {
system("clear");
cout << "You don't have enough NyscoCoins to withdraw!" << endl;
sleep(3);
system("clear");
}
}
void work() {
int work_days;
cout << "How many days do you want to work (days = seconds): ";
cin >> work_days;
cout << "Working..." << endl;
for (int i = 0; i < work_days; i++) {
system("clear");
cout << "\rWorking... " << i + 1 << " days" << endl;
sleep(1);
}
system("clear");
cout << "\nWork done!" << endl;
sleep(3);
int money_recieved = work_days * 20;
bank_balance += money_recieved;
cout << "\nYou recieved " << money_recieved << "$ for working " << work_days << " days." << endl;
sleep(3);
system("clear");
}
int main() {
system("clear");
char game_choice;
do {
cout << R"(
_ __ ______ _
/ | / /_ ________________ / ____/___ ______(_)___ ____
/ |/ / / / / ___/ ___/ __ \ / / / __ `/ ___/ / __ \/ __ \
/ /| / /_/ (__ ) /__/ /_/ / / /___/ /_/ (__ ) / / / / /_/ /
/_/ |_/\__, /____/\___/\____/ \____/\__,_/____/_/_/ /_/\____/
/____/
--------------------------------------------------------------------------
)" << endl;
cout << "Your current bank balance: " << bank_balance << "$" << endl;
cout << "Your current casino balance: " << balance << " NyscoCoins" << endl;
cout << "--------------------" << endl;
cout << "CHOOSE THE GAME: " << endl;
cout << "--------------------" << endl;
cout << "(C) - Coinflip" << endl;
cout << "(S) - Slots" << endl;
cout << "(B) - Blackjack" << endl;
cout << "(R) - Roulette (coming soon!)" << endl;
cout << "(D) - Dice Roll" << endl;
cout << "(H) - Higher or Lower (coming soon!)" << endl;
cout << "--------------------" << endl;
cout << "(J) - Go To Work" << endl;
cout << "--------------------" << endl;
cout << "(M) - Deposit Money" << endl;
cout << "(W) - Withdraw NyscoCoins" << endl;
cout << "--------------------" << endl;
cout << "(Q) - Quit" << endl;
cout << "Enter your choice: ";
cin >> game_choice;
switch (game_choice) {
case 'C': case 'c':
system("clear");
coinflip();
break;
case 'S': case 's':
system("clear");
slots();
break;
case 'B': case 'b':
system("clear");
blackjack();
break;
case 'R': case 'r':
system("clear");
roulette();
break;
case 'D': case 'd':
system("clear");
diceRoll();
break;
case 'H': case 'h':
system("clear");
higherOrLower();
break;
case 'M': case 'm':
system("clear");
deposit();
break;
case 'W': case 'w':
system("clear");
withdraw();
break;
case 'J': case 'j':
system("clear");
work();
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');
system("pause");
return 0;
}