Highest card game (Gamble!!!!!) Graphical prompt version

(1/1)

rickynl:
Like i said, i present:
Hcardgamev1.1
Code:

/*
Credits go to Richard marks for Teaching me this stuff and Helping me with certain stuff in this game.
*/

// main.cpp
// Project: Basic Console Template v9.0
// Author: Richard Marks <ccpsceo@gmail.com>

// include our easy input handling library
#include "easy_console_input.h"

// optional avoid needing the std:: prefix for C++ standard library functions
using namespace std;

// there is always a starting point for every program..and this is it!
int main(int argc, char* argv[])
{
    // write your code here!
    const char cards[]=
        {'A','K','Q','J','X','9','8','7','6','5','4','3','2'};
    char playing='y';
    bool gameover=false;
    const long bank=1000000;
    long cash=100;
    long bet=0;
    int bankcard=0;
    int usercard=0;
    while ('y'==playing||'Y'==playing)
    {
        if (gameover)
        {
            playing=get_user_input_char("Want to play another game?? (Y/N)\n");
                    gameover=false;
                    cash=100;
        }

        while (!gameover)
        {
            cout <<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nYour current cash amount is: "<<cash<<"\n";
            if (cash > 0)
            {
                if (cash < bank)
                {
                 bet= get_user_input_long("Place your bet: ");
                 if(cash>=bet)
                    {
                        srand(time(0));
                        bankcard= rand() % 12;
                        usercard= rand() % 12;

                        cout <<"\nYou pulled: "<<cards[12 - usercard]<<"\n";
                        cout <<"The bank pulled......\n";

                        sleep(2);

                        cout <<"The bank pulled: "<<cards[12 -bankcard]<<"\n";

      char dc = cards[12 - bankcard]; // dealer's card character

      char pc = cards[12 - usercard]; // player's card character

      cout <<
//Credits for the card display go to The great man: Richard Marks
      "        PLAYER        DEALER    \n"
      "        _______       _______   \n"
      "       /       \\     /       \\  \n"
      "       | " << pc << "     |     | " << dc << "     |  \n"
      "       |       |     |       |  \n"
      "       |       |     |       |  \n"
      "       |       |     |       |  \n"
      "       |     " << pc << " |     |     " << dc << " |  \n"
      "       \\_______/     \\_______/  \n\n";
// The credits go untill here
                    if (usercard > bankcard)
                    {
                     cout <<"You've got the highest card," <<bet<<" has been added to your cash\n";
                     cash +=bet;
                     cout <<"Press enter to continue:\n";
                      cin.get();
                    }
                    else if(usercard < bankcard)
                    {
                        cout<<"You've got the lowest card,"<<bet<<" has been substracted from your cash\n";
                        cash -=bet;
                        cout <<"Press enter to continue:\n";
                         cin.get();
                    }
                    else
                    {
                        cout<<"Draw, nothing happens.\n";
                        cout <<"Press enter to continue:\n";
                         cin.get();
                    }

                    }
                else
                {
                    cout <<"\nYou dont have enough money to make such bet's\n";
                }
                }
                else
                {
                    cout <<"\nYou've beaten the bank!!!\n";
                    gameover=true;
                }

            }
            else
            {
                cout << "\nYou've gone bankrupt LOSER!!\n";
                gameover=true;
            }


        }
    }



    return 0;
}

Richard Marks:
Hey Rick, I'm glad that you enjoyed the lesson, and thanks for giving me credit. :D
I can't wait until the next lesson. Let me know when you want to schedule it. 8)

Navigation

[0] Message Index