2025-02-07 12:35:03 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <ctime>
|
2025-02-07 23:12:37 +00:00
|
|
|
#include <unistd.h>
|
2025-02-07 12:35:03 +01:00
|
|
|
|
|
|
|
using namespace std;
|
2025-02-07 23:12:37 +00:00
|
|
|
char end_choice;
|
2025-02-07 12:35:03 +01:00
|
|
|
int balance = 0;
|
2025-02-07 23:12:37 +00:00
|
|
|
int bank_balance = 10000;
|
2025-02-07 12:35:03 +01:00
|
|
|
|
|
|
|
void coinflip() {
|
2025-02-07 23:12:37 +00:00
|
|
|
srand(time(0)); // Seed the random number generator
|
2025-02-07 12:35:03 +01:00
|
|
|
|
|
|
|
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;
|
2025-02-07 23:12:37 +00:00
|
|
|
sleep(3);
|
2025-02-07 12:35:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2025-02-07 23:12:37 +00:00
|
|
|
coinflip();
|
2025-02-07 12:35:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2025-02-07 23:12:37 +00:00
|
|
|
sleep(3);
|
2025-02-07 12:35:03 +01:00
|
|
|
|
|
|
|
if (flip_result == 0) {
|
|
|
|
cout << "The result is Heads!" << endl;
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-07 12:35:03 +01:00
|
|
|
cout << "The result is Tails!" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the user won or lost
|
|
|
|
if ((user_choice == 'H' || user_choice == 'h') && flip_result == 0) {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 12:35:03 +01:00
|
|
|
cout << "Congratulations! You won! You get double the bet amount." << endl;
|
|
|
|
balance += 2 * bet_amount;
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else if ((user_choice == 'T' || user_choice == 't') && flip_result == 1) {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 12:35:03 +01:00
|
|
|
cout << "Congratulations! You won! You get double the bet amount." << endl;
|
|
|
|
balance += 2 * bet_amount;
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 12:35:03 +01:00
|
|
|
cout << "Sorry! You lost the bet. Better luck next time!" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
cout << "Your new balance is: " << balance << " NyscoCoins" << endl;
|
2025-02-07 23:12:37 +00:00
|
|
|
|
|
|
|
cout << "Play again? (Y/N): ";
|
|
|
|
cin >> end_choice;
|
|
|
|
|
|
|
|
if (end_choice == 'y' || end_choice == 'Y') {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
coinflip();
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
}
|
2025-02-07 12:35:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void slots() {
|
2025-02-07 23:12:37 +00:00
|
|
|
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;
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else if (slot1 == slot2 || slot2 == slot3 || slot1 == slot3) {
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "Nice! You won double your bet amount!" << endl;
|
|
|
|
balance += 2 * bet_amount;
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-07 23:12:37 +00:00
|
|
|
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') {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
slots();
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
while (choice == 'H' || choice == 'h');
|
2025-02-07 23:12:37 +00:00
|
|
|
|
|
|
|
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
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else if (playerTotal < dealerTotal) {
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "Dealer wins! You lose your bet." << endl;
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-07 23:12:37 +00:00
|
|
|
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') {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
blackjack();
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2025-02-08 00:30:46 +01:00
|
|
|
if (total == outcome) {
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "Congratulations! You won double your bet amount!" << endl;
|
|
|
|
balance += 2 * bet_amount;
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-07 23:12:37 +00:00
|
|
|
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') {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
diceRoll();
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
else {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void higherOrLower() {
|
|
|
|
cout << "Higher or Lower game logic coming soon!" << endl;
|
2025-02-07 12:35:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void deposit() {
|
|
|
|
int deposit_amount;
|
|
|
|
cout << "Enter the amount of money you want to deposit: ";
|
|
|
|
cin >> deposit_amount;
|
2025-02-07 23:12:37 +00:00
|
|
|
if (bank_balance >= deposit_amount) {
|
|
|
|
balance += deposit_amount;
|
|
|
|
bank_balance -= deposit_amount;
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "Deposit successful! Your new balance is: " << balance << " NyscoCoins"<< endl;
|
|
|
|
sleep(3);
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
}
|
|
|
|
else {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "You don't have enough money in your bank account!" << endl;
|
|
|
|
sleep(3);
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "Deposit successful! Your new balance is: " << balance << " NyscoCoins" << endl;
|
|
|
|
sleep(3);
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
}
|
|
|
|
else {
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "You don't have enough NyscoCoins to withdraw!" << endl;
|
|
|
|
sleep(3);
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
}
|
2025-02-07 12:35:03 +01:00
|
|
|
}
|
|
|
|
|
2025-02-08 00:55:04 +01:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2025-02-07 12:35:03 +01:00
|
|
|
int main() {
|
2025-02-08 00:55:04 +01:00
|
|
|
system("clear");
|
2025-02-07 12:35:03 +01:00
|
|
|
char game_choice;
|
|
|
|
|
|
|
|
do {
|
|
|
|
cout << R"(
|
|
|
|
_ __ ______ _
|
|
|
|
/ | / /_ ________________ / ____/___ ______(_)___ ____
|
|
|
|
/ |/ / / / / ___/ ___/ __ \ / / / __ `/ ___/ / __ \/ __ \
|
|
|
|
/ /| / /_/ (__ ) /__/ /_/ / / /___/ /_/ (__ ) / / / / /_/ /
|
|
|
|
/_/ |_/\__, /____/\___/\____/ \____/\__,_/____/_/_/ /_/\____/
|
|
|
|
/____/
|
|
|
|
--------------------------------------------------------------------------
|
2025-02-07 23:12:37 +00:00
|
|
|
)" << endl;
|
2025-02-07 12:35:03 +01:00
|
|
|
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "Your current bank balance: " << bank_balance << "$" << endl;
|
|
|
|
cout << "Your current casino balance: " << balance << " NyscoCoins" << endl;
|
|
|
|
cout << "--------------------" << endl;
|
2025-02-07 12:35:03 +01:00
|
|
|
cout << "CHOOSE THE GAME: " << endl;
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "--------------------" << endl;
|
2025-02-07 12:35:03 +01:00
|
|
|
cout << "(C) - Coinflip" << endl;
|
|
|
|
cout << "(S) - Slots" << endl;
|
2025-02-07 23:12:37 +00:00
|
|
|
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;
|
2025-02-08 00:55:04 +01:00
|
|
|
cout << "(J) - Go To Work" << endl;
|
|
|
|
cout << "--------------------" << endl;
|
2025-02-07 23:12:37 +00:00
|
|
|
cout << "(M) - Deposit Money" << endl;
|
|
|
|
cout << "(W) - Withdraw NyscoCoins" << endl;
|
|
|
|
cout << "--------------------" << endl;
|
|
|
|
cout << "(Q) - Quit" << endl;
|
2025-02-07 12:35:03 +01:00
|
|
|
cout << "Enter your choice: ";
|
|
|
|
cin >> game_choice;
|
|
|
|
|
|
|
|
switch (game_choice) {
|
2025-02-07 23:12:37 +00:00
|
|
|
case 'C': case 'c':
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 12:35:03 +01:00
|
|
|
coinflip();
|
|
|
|
break;
|
2025-02-07 23:12:37 +00:00
|
|
|
case 'S': case 's':
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 12:35:03 +01:00
|
|
|
slots();
|
|
|
|
break;
|
2025-02-07 23:12:37 +00:00
|
|
|
case 'B': case 'b':
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
blackjack();
|
|
|
|
break;
|
|
|
|
case 'R': case 'r':
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
roulette();
|
|
|
|
break;
|
|
|
|
case 'D': case 'd':
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
diceRoll();
|
|
|
|
break;
|
|
|
|
case 'H': case 'h':
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
higherOrLower();
|
|
|
|
break;
|
|
|
|
case 'M': case 'm':
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 12:35:03 +01:00
|
|
|
deposit();
|
|
|
|
break;
|
2025-02-07 23:12:37 +00:00
|
|
|
case 'W': case 'w':
|
2025-02-08 00:30:46 +01:00
|
|
|
system("clear");
|
2025-02-07 23:12:37 +00:00
|
|
|
withdraw();
|
|
|
|
break;
|
2025-02-08 00:55:04 +01:00
|
|
|
case 'J': case 'j':
|
|
|
|
system("clear");
|
|
|
|
work();
|
|
|
|
break;
|
2025-02-07 23:12:37 +00:00
|
|
|
case 'Q': case 'q':
|
2025-02-07 12:35:03 +01:00
|
|
|
cout << "Thanks for playing!" << endl;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cout << "Invalid choice. Please try again." << endl;
|
|
|
|
break;
|
|
|
|
}
|
2025-02-08 00:55:04 +01:00
|
|
|
}
|
|
|
|
while (game_choice != 'Q' && game_choice != 'q');
|
2025-02-07 12:35:03 +01:00
|
|
|
|
2025-02-07 23:12:37 +00:00
|
|
|
system("pause");
|
2025-02-07 12:35:03 +01:00
|
|
|
return 0;
|
|
|
|
}
|