Compare commits

...

6 Commits

Author SHA1 Message Date
b33a371b83 change the balance checking to bool 2025-02-12 10:39:28 +01:00
bb0953bfe3 fix higherOrLower 2025-02-10 13:16:05 +01:00
9be01f4faa Update main.cpp 2025-02-09 23:27:22 +00:00
Sebastian Ranoszek
0cffa95dc3 add signature 2025-02-09 23:25:50 +01:00
Sebastian Ranoszek
f1dc2afc36 complete code rewrite for windows 2025-02-09 22:55:03 +01:00
Sebastian Ranoszek
7a0c3adc4b switch <unistd.h> to <Windows.h> and change sleep func 2025-02-09 22:50:24 +01:00
4 changed files with 95 additions and 76 deletions

3
.gitignore vendored
View File

@ -1,2 +1 @@
.vscode/ main.exe
.Makefile/

View File

@ -1,2 +0,0 @@
all:
g++ -o main main.cpp

BIN
main

Binary file not shown.

166
main.cpp
View File

@ -1,7 +1,22 @@
/*
*
* NyscoCasino
* Created by Nyosic | (C) 2025
* https://gitea.lossless.win/nyosic │
*
*
* (\_/)
* (o.o)
* (> <)
*
* Version: 1.1.3
* Date: [2025-02-09]
*/
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <ctime> #include <ctime>
#include <unistd.h> #include <Windows.h>
using namespace std; using namespace std;
char end_choice; char end_choice;
@ -9,19 +24,34 @@ int balance = 0;
int bank_balance = 10000; int bank_balance = 10000;
int save_depo = 0; int save_depo = 0;
void display_balance(){
cout << "Your current casino balance: " << balance << " NyscoCoins" << endl;
}
bool check_balance(int bet_amount) {
if (bet_amount > balance) {
cout << "Insufficient funds. Please deposit more money." << endl;
Sleep(3000);
return false;
}
else {
return true;
}
}
void coinflip() { void coinflip() {
srand(time(0)); // Seed the random number generator srand(time(0)); // Seed the random number generator
int bet_amount; int bet_amount;
char user_choice; char user_choice;
display_balance();
cout << "Enter the amount of money you want to bet on the coin flip: "; cout << "Enter the amount of money you want to bet on the coin flip: ";
cin >> bet_amount; cin >> bet_amount;
// Check if the user has enough balance // Check if the user has enough balance
if (bet_amount > balance) { if (!check_balance(bet_amount)) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl; return;
sleep(3);
} }
// Deduct the bet amount from the balance // Deduct the bet amount from the balance
@ -44,7 +74,7 @@ void coinflip() {
cout << "The coin is flipping..." << endl; cout << "The coin is flipping..." << endl;
// Wait a moment to simulate flipping // Wait a moment to simulate flipping
sleep(3); Sleep(3000);
if (flip_result == 0) { if (flip_result == 0) {
cout << "The result is Heads!" << endl; cout << "The result is Heads!" << endl;
@ -55,17 +85,17 @@ void coinflip() {
// Check if the user won or lost // Check if the user won or lost
if ((user_choice == 'H' || user_choice == 'h') && flip_result == 0) { if ((user_choice == 'H' || user_choice == 'h') && flip_result == 0) {
system("clear"); system("cls");
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("cls");
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("cls");
cout << "Sorry! You lost the bet. Better luck next time!" << endl; cout << "Sorry! You lost the bet. Better luck next time!" << endl;
} }
@ -75,11 +105,11 @@ void coinflip() {
cin >> end_choice; cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("cls");
coinflip(); coinflip();
} }
else { else {
system("clear"); system("cls");
} }
} }
@ -88,18 +118,18 @@ void slots() {
int bet_amount; int bet_amount;
char end_choice; char end_choice;
display_balance();
cout << "Enter the amount of money you want to bet on slots: "; cout << "Enter the amount of money you want to bet on slots: ";
cin >> bet_amount; cin >> bet_amount;
if (bet_amount > balance) { if (!check_balance(bet_amount)) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl; return;
sleep(3);
} }
balance -= bet_amount; balance -= bet_amount;
cout << "Spinning the slots..." << endl; cout << "Spinning the slots..." << endl;
sleep(2); Sleep(2000);
int slot1 = rand() % 5 + 1; int slot1 = rand() % 5 + 1;
int slot2 = rand() % 5 + 1; int slot2 = rand() % 5 + 1;
@ -125,11 +155,11 @@ void slots() {
cin >> end_choice; cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("cls");
slots(); slots();
} }
else { else {
system("clear"); system("cls");
} }
} }
@ -148,12 +178,12 @@ void blackjack() {
cout << "Your cards: " << playerCard1 << " and " << playerCard2 << " (Total: " << playerTotal << ")" << endl; cout << "Your cards: " << playerCard1 << " and " << playerCard2 << " (Total: " << playerTotal << ")" << endl;
cout << "Dealer's visible card: " << dealerCard1 << endl; cout << "Dealer's visible card: " << dealerCard1 << endl;
display_balance();
cout << "Enter your bet amount: "; cout << "Enter your bet amount: ";
cin >> bet_amount; cin >> bet_amount;
if (bet_amount > balance) { if (!check_balance(bet_amount)) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl; return;
sleep(3);
} }
balance -= bet_amount; balance -= bet_amount;
@ -201,11 +231,11 @@ void blackjack() {
cin >> end_choice; cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("cls");
blackjack(); blackjack();
} }
else { else {
system("clear"); system("cls");
} }
} }
@ -218,28 +248,27 @@ void diceRoll() {
int bet_amount, outcome; int bet_amount, outcome;
char end_choice; char end_choice;
display_balance();
cout << "Enter the amount of money you want to bet on dice roll: "; cout << "Enter the amount of money you want to bet on dice roll: ";
cin >> bet_amount; cin >> bet_amount;
if (!check_balance(bet_amount)) {
return;
}
cout << "Guess the outcome: "; cout << "Guess the outcome: ";
cin >> 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) { if (outcome > 12) {
cout << "There are only two dices max number is 12" << endl; cout << "There are only two dices max number is 12" << endl;
sleep(3); Sleep(3000);
diceRoll(); diceRoll();
} }
balance -= bet_amount; balance -= bet_amount;
cout << "Rolling the dice..." << endl; cout << "Rolling the dice..." << endl;
sleep(2); Sleep(2000);
int dice1 = rand() % 6 + 1; int dice1 = rand() % 6 + 1;
int dice2 = rand() % 6 + 1; int dice2 = rand() % 6 + 1;
@ -261,11 +290,11 @@ void diceRoll() {
cin >> end_choice; cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("cls");
diceRoll(); diceRoll();
} }
else { else {
system("clear"); system("cls");
} }
} }
@ -276,6 +305,7 @@ void higherOrLower() {
char outcome; char outcome;
char end_choice; char end_choice;
display_balance();
cout << "Enter the amount of money you want to bet on higer or lower: "; cout << "Enter the amount of money you want to bet on higer or lower: ";
cin >> bet_amount; cin >> bet_amount;
@ -285,22 +315,14 @@ void higherOrLower() {
cout << "Guess the outcome (H-Higher/L-Lower): "; cout << "Guess the outcome (H-Higher/L-Lower): ";
cin >> outcome; cin >> outcome;
if (bet_amount > balance) { if (!check_balance(bet_amount)) {
cout << "You don't have enough NyscoCoins! Please try again with a lower amount." << endl; return;
sleep(3);
higherOrLower();
}
if (outcome > 100 || outcome < 1) {
cout << "The range is from 1 to 100" << endl;
sleep(3);
higherOrLower();
} }
balance -= bet_amount; balance -= bet_amount;
cout << "Generating the output number.." << endl; cout << "Generating the output number.." << endl;
sleep(2); Sleep(2000);
int end_number = rand() % 100 + 1; int end_number = rand() % 100 + 1;
@ -336,11 +358,11 @@ void higherOrLower() {
cin >> end_choice; cin >> end_choice;
if (end_choice == 'y' || end_choice == 'Y') { if (end_choice == 'y' || end_choice == 'Y') {
system("clear"); system("cls");
higherOrLower(); higherOrLower();
} }
else { else {
system("clear"); system("cls");
} }
} }
@ -352,16 +374,16 @@ void deposit() {
if (bank_balance >= deposit_amount) { if (bank_balance >= deposit_amount) {
balance += deposit_amount; balance += deposit_amount;
bank_balance -= deposit_amount; bank_balance -= deposit_amount;
system("clear"); system("cls");
cout << "Deposit successful! Your new balance is: " << balance << " NyscoCoins"<< endl; cout << "Deposit successful! Your new balance is: " << balance << " NyscoCoins"<< endl;
sleep(3); Sleep(3000);
system("clear"); system("cls");
} }
else { else {
system("clear"); system("cls");
cout << "You don't have enough money in your bank account!" << endl; cout << "You don't have enough money in your bank account!" << endl;
sleep(3); Sleep(3000);
system("clear"); system("cls");
} }
} }
@ -373,16 +395,16 @@ void withdraw() {
if (balance >= withdraw_amount) { if (balance >= withdraw_amount) {
balance -= withdraw_amount; balance -= withdraw_amount;
bank_balance += withdraw_amount; bank_balance += withdraw_amount;
system("clear"); system("cls");
cout << "Deposit successful! Your new bank balance is: " << bank_balance << "$" << endl; cout << "Deposit successful! Your new bank balance is: " << bank_balance << "$" << endl;
sleep(3); Sleep(3000);
system("clear"); system("cls");
} }
else { else {
system("clear"); system("cls");
cout << "You don't have enough NyscoCoins to withdraw!" << endl; cout << "You don't have enough NyscoCoins to withdraw!" << endl;
sleep(3); Sleep(3000);
system("clear"); system("cls");
} }
} }
@ -394,22 +416,22 @@ void work() {
cout << "Working..." << endl; cout << "Working..." << endl;
for (int i = 0; i < work_days; i++) { for (int i = 0; i < work_days; i++) {
system("clear"); system("cls");
cout << "\rWorking... " << i + 1 << " days" << endl; cout << "\rWorking... " << i + 1 << " days" << endl;
sleep(1); Sleep(1000);
} }
system("clear"); system("cls");
cout << "\nWork done!" << endl; cout << "\nWork done!" << endl;
sleep(3); Sleep(3000);
int money_recieved = work_days * 120; int money_recieved = work_days * 120;
bank_balance += money_recieved * 0.88; bank_balance += money_recieved * 0.88;
cout << "\nYou recieved " << money_recieved * 0.88 << "$ (after tax) for working " << work_days << " days." << endl; cout << "\nYou recieved " << money_recieved * 0.88 << "$ (after tax) for working " << work_days << " days." << endl;
sleep(3); Sleep(3000);
system("clear"); system("cls");
} }
int main() { int main() {
system("clear"); system("cls");
char game_choice; char game_choice;
do { do {
@ -446,39 +468,39 @@ int main() {
switch (game_choice) { switch (game_choice) {
case 'C': case 'c': case 'C': case 'c':
system("clear"); system("cls");
coinflip(); coinflip();
break; break;
case 'S': case 's': case 'S': case 's':
system("clear"); system("cls");
slots(); slots();
break; break;
case 'B': case 'b': case 'B': case 'b':
system("clear"); system("cls");
blackjack(); blackjack();
break; break;
case 'R': case 'r': case 'R': case 'r':
system("clear"); system("cls");
roulette(); roulette();
break; break;
case 'D': case 'd': case 'D': case 'd':
system("clear"); system("cls");
diceRoll(); diceRoll();
break; break;
case 'H': case 'h': case 'H': case 'h':
system("clear"); system("cls");
higherOrLower(); higherOrLower();
break; break;
case 'M': case 'm': case 'M': case 'm':
system("clear"); system("cls");
deposit(); deposit();
break; break;
case 'W': case 'w': case 'W': case 'w':
system("clear"); system("cls");
withdraw(); withdraw();
break; break;
case 'J': case 'j': case 'J': case 'j':
system("clear"); system("cls");
work(); work();
break; break;
case 'Q': case 'q': case 'Q': case 'q':