diff --git a/.gitignore b/.gitignore index dbe9c82..8e50d53 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.vscode/ \ No newline at end of file +.vscode/ +.Makefile/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a200f34 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +all: + g++ -o main main.cpp diff --git a/main b/main index 9ef100c..9e8a101 100755 Binary files a/main and b/main differ diff --git a/main.cpp b/main.cpp index ef9a486..c811cc5 100644 --- a/main.cpp +++ b/main.cpp @@ -7,6 +7,7 @@ using namespace std; char end_choice; int balance = 0; int bank_balance = 10000; +int save_depo = 0; void coinflip() { srand(time(0)); // Seed the random number generator @@ -47,7 +48,7 @@ void coinflip() { if (flip_result == 0) { cout << "The result is Heads!" << endl; - } + } else { cout << "The result is Tails!" << endl; } @@ -57,26 +58,26 @@ void coinflip() { 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"); } @@ -109,11 +110,11 @@ void slots() { 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; } @@ -122,11 +123,11 @@ void slots() { cout << "Play again? (Y/N): "; cin >> end_choice; - + if (end_choice == 'y' || end_choice == 'Y') { system("clear"); slots(); - } + } else { system("clear"); } @@ -171,7 +172,7 @@ void blackjack() { cout << "You bust! Dealer wins." << endl; } } - } + } while (choice == 'H' || choice == 'h'); cout << "Dealer's turn. Dealer's total is " << dealerTotal << "." << endl; @@ -185,24 +186,24 @@ void blackjack() { 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"); } @@ -219,7 +220,7 @@ void diceRoll() { cout << "Enter the amount of money you want to bet on dice roll: "; cin >> bet_amount; - + cout << "Guess the outcome: "; cin >> outcome; @@ -228,7 +229,7 @@ void diceRoll() { sleep(3); diceRoll(); } - + if (outcome > 12) { cout << "There are only two dices max number is 12" << endl; sleep(3); @@ -249,7 +250,7 @@ void diceRoll() { 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; } @@ -258,11 +259,11 @@ void diceRoll() { cout << "Play again? (Y/N): "; cin >> end_choice; - + if (end_choice == 'y' || end_choice == 'Y') { system("clear"); diceRoll(); - } + } else { system("clear"); } @@ -270,7 +271,77 @@ void diceRoll() { void higherOrLower() { - cout << "Higher or Lower game logic coming soon!" << endl; + srand(time(0)); + int bet_amount; + char outcome; + char end_choice; + + cout << "Enter the amount of money you want to bet on higer or lower: "; + cin >> bet_amount; + + int start_number = rand() % 100 + 1; + cout << "Starting number: " << start_number << endl; + + cout << "Guess the outcome (H-Higher/L-Lower): "; + cin >> outcome; + + if (bet_amount > balance) { + cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl; + sleep(3); + higherOrLower(); + } + + if (outcome > 100 || outcome < 1) { + cout << "The range is from 1 to 100" << endl; + sleep(3); + higherOrLower(); + } + + balance -= bet_amount; + + cout << "Generating the output number.." << endl; + sleep(2); + + int end_number = rand() % 100 + 1; + + if(start_number > end_number) { + cout << "You guessed: " << outcome << " (The outcome is: " << end_number << " and its lower!)" << endl; + } + else if(start_number < end_number) { + cout << "You guessed: " << outcome << " (The outcome is: " << end_number << " and its higher!)" << endl; + } + + if (outcome == 'H' || outcome == 'h') { + if (start_number < end_number) { + cout << "Congratulations! You won double your bet amount!" << endl; + balance += 2 * bet_amount; + } + else { + cout << "You lost! Better luck next time!" << endl; + } + } + else if (outcome == 'L' || outcome == 'l') { + if (start_number > end_number) { + 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"); + higherOrLower(); + } + else { + system("clear"); + } } void deposit() { @@ -299,10 +370,9 @@ void withdraw() { cin >> withdraw_amount; if (balance >= withdraw_amount) { balance -= withdraw_amount; - bank_balance += withdraw_amount * 0.76; + bank_balance += withdraw_amount; system("clear"); - cout << "Deposit successful! Your new bank balance is: " << bank_balance << "$ (after tax)" << endl; - cout << "Gambling is also taxed!" << endl; + cout << "Deposit successful! Your new bank balance is: " << bank_balance << "$" << endl; sleep(3); system("clear"); } @@ -342,11 +412,11 @@ int main() { do { cout << R"( - _ __ ______ _ - / | / /_ ________________ / ____/___ ______(_)___ ____ + _ __ ______ _ + / | / /_ ________________ / ____/___ ______(_)___ ____ / |/ / / / / ___/ ___/ __ \ / / / __ `/ ___/ / __ \/ __ \ / /| / /_/ (__ ) /__/ /_/ / / /___/ /_/ (__ ) / / / / /_/ / - /_/ |_/\__, /____/\___/\____/ \____/\__,_/____/_/_/ /_/\____/ + /_/ |_/\__, /____/\___/\____/ \____/\__,_/____/_/_/ /_/\____/ /____/ -------------------------------------------------------------------------- )" << endl; @@ -416,7 +486,7 @@ int main() { cout << "Invalid choice. Please try again." << endl; break; } - } + } while (game_choice != 'Q' && game_choice != 'q'); system("pause");