add work for making money

This commit is contained in:
nyosic 2025-02-08 00:55:04 +01:00
parent cff8a06d14
commit 2029666ea5
2 changed files with 57 additions and 14 deletions

BIN
main

Binary file not shown.

View File

@ -47,7 +47,8 @@ void coinflip() {
if (flip_result == 0) { if (flip_result == 0) {
cout << "The result is Heads!" << endl; cout << "The result is Heads!" << endl;
} else { }
else {
cout << "The result is Tails!" << endl; cout << "The result is Tails!" << endl;
} }
@ -56,11 +57,13 @@ void coinflip() {
system("clear"); system("clear");
cout << "Congratulations! You won! You get double the bet amount." << endl; cout << "Congratulations! You won! You get double the bet amount." << endl;
balance += 2 * bet_amount; balance += 2 * bet_amount;
} else if ((user_choice == 'T' || user_choice == 't') && flip_result == 1) { }
else if ((user_choice == 'T' || user_choice == 't') && flip_result == 1) {
system("clear"); system("clear");
cout << "Congratulations! You won! You get double the bet amount." << endl; cout << "Congratulations! You won! You get double the bet amount." << endl;
balance += 2 * bet_amount; balance += 2 * bet_amount;
} else { }
else {
system("clear"); system("clear");
cout << "Sorry! You lost the bet. Better luck next time!" << endl; cout << "Sorry! You lost the bet. Better luck next time!" << endl;
} }
@ -73,7 +76,8 @@ void coinflip() {
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("clear");
coinflip(); coinflip();
} else { }
else {
system("clear"); system("clear");
} }
} }
@ -105,10 +109,12 @@ void slots() {
if (slot1 == slot2 && slot2 == slot3) { if (slot1 == slot2 && slot2 == slot3) {
cout << "JACKPOT! You won triple your bet amount!" << endl; cout << "JACKPOT! You won triple your bet amount!" << endl;
balance += 3 * bet_amount; balance += 3 * bet_amount;
} else if (slot1 == slot2 || slot2 == slot3 || slot1 == slot3) { }
else if (slot1 == slot2 || slot2 == slot3 || slot1 == slot3) {
cout << "Nice! You won double your bet amount!" << endl; cout << "Nice! You won double your bet amount!" << endl;
balance += 2 * bet_amount; balance += 2 * bet_amount;
} else { }
else {
cout << "You lost! Better luck next time!" << endl; cout << "You lost! Better luck next time!" << endl;
} }
@ -120,7 +126,8 @@ void slots() {
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("clear");
slots(); slots();
} else { }
else {
system("clear"); system("clear");
} }
} }
@ -164,7 +171,8 @@ void blackjack() {
cout << "You bust! Dealer wins." << endl; cout << "You bust! Dealer wins." << endl;
} }
} }
} while (choice == 'H' || choice == 'h'); }
while (choice == 'H' || choice == 'h');
cout << "Dealer's turn. Dealer's total is " << dealerTotal << "." << endl; cout << "Dealer's turn. Dealer's total is " << dealerTotal << "." << endl;
@ -177,9 +185,11 @@ void blackjack() {
if (dealerTotal > 21 || playerTotal > dealerTotal) { if (dealerTotal > 21 || playerTotal > dealerTotal) {
cout << "You win! You gain " << bet_amount << " NyscoCoins." << endl; cout << "You win! You gain " << bet_amount << " NyscoCoins." << endl;
balance += 2 * bet_amount; // Win pays 2:1 balance += 2 * bet_amount; // Win pays 2:1
} else if (playerTotal < dealerTotal) { }
else if (playerTotal < dealerTotal) {
cout << "Dealer wins! You lose your bet." << endl; cout << "Dealer wins! You lose your bet." << endl;
} else { }
else {
cout << "It's a tie! Your bet is returned." << endl; cout << "It's a tie! Your bet is returned." << endl;
balance += bet_amount; // Return bet balance += bet_amount; // Return bet
} }
@ -192,7 +202,8 @@ void blackjack() {
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("clear");
blackjack(); blackjack();
} else { }
else {
system("clear"); system("clear");
} }
} }
@ -238,7 +249,8 @@ void diceRoll() {
if (total == outcome) { if (total == outcome) {
cout << "Congratulations! You won double your bet amount!" << endl; cout << "Congratulations! You won double your bet amount!" << endl;
balance += 2 * bet_amount; balance += 2 * bet_amount;
} else { }
else {
cout << "You lost! Better luck next time!" << endl; cout << "You lost! Better luck next time!" << endl;
} }
@ -250,7 +262,8 @@ void diceRoll() {
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("clear");
diceRoll(); diceRoll();
} else { }
else {
system("clear"); system("clear");
} }
} }
@ -300,7 +313,30 @@ void withdraw() {
} }
} }
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() { int main() {
system("clear");
char game_choice; char game_choice;
do { do {
@ -326,6 +362,8 @@ int main() {
cout << "(D) - Dice Roll" << endl; cout << "(D) - Dice Roll" << endl;
cout << "(H) - Higher or Lower (coming soon!)" << endl; cout << "(H) - Higher or Lower (coming soon!)" << endl;
cout << "--------------------" << endl; cout << "--------------------" << endl;
cout << "(J) - Go To Work" << endl;
cout << "--------------------" << endl;
cout << "(M) - Deposit Money" << endl; cout << "(M) - Deposit Money" << endl;
cout << "(W) - Withdraw NyscoCoins" << endl; cout << "(W) - Withdraw NyscoCoins" << endl;
cout << "--------------------" << endl; cout << "--------------------" << endl;
@ -366,6 +404,10 @@ int main() {
system("clear"); system("clear");
withdraw(); withdraw();
break; break;
case 'J': case 'j':
system("clear");
work();
break;
case 'Q': case 'q': case 'Q': case 'q':
cout << "Thanks for playing!" << endl; cout << "Thanks for playing!" << endl;
break; break;
@ -373,7 +415,8 @@ int main() {
cout << "Invalid choice. Please try again." << endl; cout << "Invalid choice. Please try again." << endl;
break; break;
} }
} while (game_choice != 'Q' && game_choice != 'q'); }
while (game_choice != 'Q' && game_choice != 'q');
system("pause"); system("pause");
return 0; return 0;