Craps game

I'm new to C++, so I have like very little knowledge...Please no complex codes.

Here's my question:
So I have created a working code for an alternate version of craps with three dice. I want a simple code to create like a "bank account" for the user to have after he pays his buy-in.

Base of the bank account, prizes and buy-ins:
$150 to start
-$7 "buy-in"
+$15 Win on first roll
+$10 Win on first roll after MyPoint
+/-$0 Loss

Here's the code, any help will be appreciated!!! :)

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
//
//  main.cpp
//  DiceGame
//
//  Created by Mark Liu on 2014-07-29.
//  Copyright (c) 2014 Mark. All rights reserved.
//

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int rollDice (void);
int n = 1;

int main(int argc, const char * argv[])
{
    while (n == 1) {
    
    enum Result {WINNER, LOSER, CONTINUE};
    int sum, MyScore = 0;
    Result gameStatus;
    
    srand(static_cast<unsigned int>(time(NULL)));
    sum = rollDice();
    
    switch ( sum )
    {
        case 7:
        case 13:
            gameStatus = WINNER;
            break;
            
        case 3:
        case 4:
        case 5:
        case 17:
        case 18:
            gameStatus = LOSER;
            break;
            
        default:
            gameStatus = CONTINUE;
            MyScore = sum;
            cout << "Your point is " << MyScore <<endl <<endl;
    }
    
        while (gameStatus == CONTINUE)
        {
            cout << "Your new roll does not equal your point.\nRe-rolling the three dice" << endl <<endl;
                sum = rollDice();
                
            if ( sum == MyScore )
            {
            cout << "Your new roll equals your point!" <<endl;
                    gameStatus = WINNER;
            }
            else
            {
                if ( sum == 10 )
                        cout << "Your new roll equals 10!!! Uh-oh :(" <<endl;
                        gameStatus = LOSER;
            }
        }
    
    if (gameStatus == WINNER)
        cout << "Player wins!!! :D " <<endl;
    else
        cout << "Player loses... :(" <<endl;
    

    int n;
    
    cout << "Enter 1 to play again, otherwise, enter 2\n";
    cin >> n;
    
    if (n == 1)
        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\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";
    
    else
        
    {
        cout << "Thank you for playing " << endl;
        return 0;
    }
}
    
    
}
int rollDice (void)
{
    int die1, die2, die3, findSum;
    
    die1 = 1+ rand() % 6;
    die2 = 1+ rand() % 6;
    die3 = 1+ rand() % 6;
    findSum = die1 + die2 +die3;
    cout << "Player rolled: a " << die1 << " a " <<die2 << ", and a " <<die3 << " totalling " << findSum <<endl;
    
    return findSum;
    
}n findSum;
    
}



Also, what forum should questions like these be posted in?


Thanks!
Last edited on
So I have created a working code for an alternate version of craps with three dice. I want a simple code to create like a "bank account" for the user to have after he pays his buy-in


not really a question... But I'm guessing you want to make a bank? btw your code has syntax errors.

If it were me, I'd create a float (or in your case maybe an integer) named bank, and then just simply add/subtract conditionally.
Last edited on
Also, what forum should questions like these be posted in?
Beginners.

$150 to start
int money = 150; //give user the 150 dollars to start with then, you can simply either money -= value; (subtract) or money += value;(add) to it.

*fixed code tags
Last edited on
Ok thanks giblit! :) It worked :D
Topic archived. No new replies allowed.