Craps game

In my class we are doing a project of programming casino games
My craps game works but not the way its supposed to.
I have tried to set a wager system where the player starts off with 100 chips and wins or loses based on the results of the game; but, I am not sure why it is not working properly.
That and I'm not sure how to implement my loops to make it end the game and go back to the main menu after they have won or lost.
Any help would be greatly appreciated :]

Here is what my game is supposed to do exactly:
1
2
3
4
5
6
7
8
9
10
11
12
Craps is a game that takes place over two rounds. 
In round one, two dice are rolled. If the sum of the dice is either 7 or 11, 
you win your bet (known as the line bet). 
If it’s 2,3 or 12, you lose, otherwise known as craps. 
If it is any other number, the next round begins.

In round 2, two dice are rolled. If the roll is 7, all bets are lost. 
Otherwise, the rolls continue until the first number rolled is rolled again, 
winning the bet, and starting at round 1 again.

Additional functionally such as side bets, odd bets, 
and other bets are not necessary.


Here is the bit I was having trouble implementing about the betting system:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
The game to be played will be selected by the user using a menu-based system. 
The user should be able to continue playing individual games or
 choose to play a new game at any time. Each game has their own 
specifications. The user begins with a total of 100 chips (dollars).

The user’s chips carry over every game. As stated before,
 the user can opt to continue playing a game, or select a new game.
 The user’s chips should be displayed after every round, 
no matter what game is being played. The current amount of chips 
should be shown at the main menu also. After every new game is 
selected, whether it is a transition into a new game or a 
continuation of a game, the entire console should become clear. 
The console should also clear for every new menu prompt. 
These specifications fall under the menu-based system of the grade specifications.


Keep in mind I know my second game isn't in this but the craps game is what is giving me trouble
Finally, here is what I have:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  #include <iostream>

using namespace std;

void craps()
{
    srand(time(0));
    cout << "Welcome to Craps! \n";
    cout << "Craps is a game that takes place over two rounds. "
            "In round one, two dice are rolled. If the sum of "
            "the dice is either 7 or 11, you win your bet "
            "(known as the line bet). If it’s 2,3 or 12, you "
            " lose, otherwise known as craps. If it is any "
            "other number, the next round begins.\n";
    cout << "In round 2, two dice are rolled. If the roll is 7, "
            "all bets are lost. Otherwise, the rolls continue "
            "until the first number rolled is rolled again, "
            "winning the bet, and starting at round 1 again.\n"; 
    int gamesPlayed = 0;
    int betAmount;
    int chips = 100;
    cout << "You will start off with 100 chips.\n";
    cout << "If you would care to place a wager (if no wager enter a 0) "
            "enter it here: "; 
    cin >> betAmount;
    int chipsLeft;
    char input;
    int won = 0;
    int loss = 0;
    for(int i = 0; i < 2; i++)
    {
        int firstDie1 = rand() % 6 + 1;
        int firstDie2 = rand() % 6 + 1;
        int roll = firstDie1 + firstDie2;
        cout << "Your first roll is " << roll << endl;
        if(roll == 7 || roll == 11)
        {
            cout << "You won! ";
            gamesPlayed++;
            won++;
            chipsLeft = chips + betAmount;
        }
        else if (roll == 2 || roll == 3 || roll == 12)
        {
            cout << "You lose ";
            gamesPlayed++;
            chipsLeft = chips - betAmount;
            loss++;
                   
        }
        else
        {
            cout << "Next round! ";
    do{ 
        int secondDie1 = rand() % 6 + 1;
        int secondDie2 = rand() % 6 + 1;
        int rollTwo = secondDie1 + secondDie2;
        cout << "Your next roll is " << rollTwo << endl;
        if(rollTwo == 7)
        {
            cout << "You lose";
            gamesPlayed++;
            chipsLeft = chips - betAmount;
            loss++;
        }
        else if(rollTwo == roll)
        {
            cout << "You win!";
            gamesPlayed++;
            chipsLeft = chips + betAmount;
            won++;  
        }
        cout << "Would you like to play again? Enter Y for yes";
        cin >> input;
       }while(input = 'Y');
        }
    }
    
    cout << "Thank you for playing!\n";
}

void poker()
{
    cout << "Welcome to poker! Would you like to play?";
    string input;
    cin >> input;
    
    cout << "Thank you for playing!\n";
}
int main(int argc, char** argv) {

    int choice;
    int chips = 100;
    int chipsLeft;
    do{
    cout << "---------------------------Main Menu---------------------------\n";
    cout << "-----------Choose which game you would like to play!-----------\n";
    cout << "------You have currently " << chipsLeft << " chips left.-------\n";
    cout << "---------------------------1) Craps!---------------------------\n";
    cout << "---------------------------2) Poker!---------------------------\n";
    cout << "---------------------------3) Quit-----------------------------\n";
    cin >> choice;
    
    switch(choice)
    {
        case 1:
            craps();
            break;
        case 2:
            poker();
            break;
        case 3:
            cout << "Thanks for playing!";
        default:
            cout << "Not a valid input";
    }
    }while(choice != 3);
    return 0;
}
Last edited on
I also am not sure if the rolls are randomized correctly, or how to adjust my code to make it do random rolls each time
The only issue I'm not having is implementing a betting system.
I understand that I may have to use reference paramenters but how can I implement that with what I have coded so far?
Topic archived. No new replies allowed.