Need assistance building pig dice game.

Trying to build a pig dice game that will first ask the user to pick between game A or game B. Then will proceed to have players 1 & 2 roll, while keeping track of the score. For game A (one dice game), if player 1 or 2 rolls a 1, their score goes back to 0. For game B (two dice game), if player 1 or 2 rolls snake eyes (two 1's), their score goes back to 0.

Here are the instructions:

Rewrite a Die class for simulating a dice roll and construct the game of PIG. Here are the rules:

• There are two local players

• Player 1 will go first

Single Die Rules

• The player will roll the die repeatedly, accumulating points shown on the die’s value.

• The player will continue to roll until satisfied with their score.

• If the player rolls a 1, they will lose all points earned during that round and their turn ends.

• The process will repeat until a player is the first to reach 100 points or greater.

Two Dice Rules

• The player will roll the dice repeatedly, accumulating points shown on the die’s value.

• The player will continue to roll until satisfied with their score.

• If the player rolls a 1 on either die, they will lose all points earned during that round and their turn ends.

• If the player rolls snake eyes (double 1s) they will lose all points earned and start back at 0.

• The process will repeat until a player is the first to reach 100 points or greater.

Our game should contain the following:

• 2 Player mode - Human controlled player 1 and 2

• Game mode A & B - A is single die, B is two dice

• Use validation if necessary, use programming concepts and good habits formed over lecture material.

• This is your design. The choices are yours to make.

• You will be evaluated on your level of craftsmanship of the architecture.

You will present and defend your design decisions in a class presentation as a team to the class.

System Design:

Your design should look to include course concepts. Some examples:

Inheritance – Opportunities:

Core rules

- Single player rules

- 2 player rules

Exceptions

- Check for errors with input

Multiple classes

Dynamic memory allocation

- Choose which mode and create the proper amount of dice and players necessary

And any other previously discussed course content…

-------------------------------------------------------------------

Here is my code so far:

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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161

#include<iostream>
#include<cstdlib>
using namespace std;
class Dice
{
int score1,score2;
int numberofdice;
bool turn1,turn2;
public :
Dice(int n)
{
numberofdice=n;
score1=score2=0;
turn1=turn2=false;
}
void gameOn()
{
int sc1,sc2,numondice,numondice2,s;
sc1=0;sc2=0;
  
if(numberofdice==1)
while(score1<30&&score2<100)
{
while(turn1==false&&(score2<100))
{
numondice=rand()%6+1;
if(numondice==1)
{
sc1=0;
turn1=true;
turn2=false;
}
else
{
sc1=sc1+numondice;
cout<<"\nplayer1 score in present round:"<<sc1;
cout<<"\nif satisfid with score enter 1:";
cin>>s;
if(s==1)
{
score1+=sc1;
turn1=true;
turn2=false;
}
}
}
while(turn2==false&&(score1<100&&score2<100))
{
numondice=rand()%6+1;
if(numondice==1)
{
sc2=0;
turn2=true;
turn1=false;
}
else
{
sc2=sc2+numondice;
cout<<"\nplayer2 score in present round:"<<sc2;
cout<<"\nif satisfid with score enter 1:";
cin>>s;
if(s==1)
{
score2+=sc2;
turn2=true;
turn1=false;
}
}
}
}
//...........
else
if(numberofdice==2)
while(score1<100&&score2<100)
{
while(turn1==false&&(score1<100&&score2<100))
{
numondice=rand()%6+1;
numondice2=rand()%6+1;
if((numondice==1)&&(numondice2==1))
{
sc1=0;
score1=0;
turn1=true;
turn2=false;
}
else
if((numondice==1)||(numondice2==1))
{
sc1=0;
turn1=true;
turn2=false;
}
else
{
sc1=sc1+numondice+numondice2;
cout<<"\nplayer1 score in present round:"<<sc1;
cout<<"\nif satisfid with score enter 1:";
cin>>s;
if(s==1)
{
score1+=sc1;
turn1=true;
turn2=false;
}
}
}
while(turn2==false&&(score1<100&&score2<100))
{
numondice=rand()%6+1;
numondice2=rand()%6+1;
if((numondice==1)&&(numondice2==1))
{
sc2=0;
score2=0;
turn2=true;
turn1=false;
}
else
if((numondice==1)||(numondice2==1))
{
sc2=0;
turn2=true;
turn1=false;
}
else
{
sc2=sc2+numondice+numondice2;
cout<<"\nplayer2 score in present round:"<<sc2;
cout<<"\nif satisfid with score enter 1:";
cin>>s;
if(s==1)
{
score2+=sc2;
turn2=true;
turn1=false;
}
}
}
}
if(score1>=100)
cout<<"\nPlayer1 Win with score:"<<score1;
else
cout<<"\nPlayer2 Win with score:"<<score2;
}
};
int main()
{
int n;
cout<<"\n Enter the number of Dice:";
cin>>n;
if(n==1||n==2)
{
Dice d(2);
d.gameOn();
}
else
cout<<"\n Invalid choice";
}
Trying to build a pig dice game... Here are the instructions... Here is my code so far:

And the question is...?

Topic archived. No new replies allowed.