Dice game not looping, & need help declaring winner

Making a Left Center Rigtht dice game, If someone rolls a 1(L), 3(C), or 5(R), then the player will pass a chip to the corresponding direction. But something is wrong with the code, also I need help making it so that once 2 players run out of chips, the last player with any chips will win the game. Here is my code

(edit: so the program is running but the loop isnt working, it runs the game once and ends, i need it to keep looping until someone wins)

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
ll // LCR Final Draft.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	int userOption = 0;
	int playerTurn = 0;
	int roll = 0;
	int winner;
	float round = 0;
	float player1_Chips = 3,
		player2_Chips = 3,
		player3_Chips = 3,
		pot_Chips = 0;
	string player1_name;
	string player2_name;
	string player3_name;
	time_t srand(time(0));


	// menu interface
	cout << "1. Start Left/Center/Right" << endl;
	cout << "2. How is Left/Center/Right Played?" << endl;
	cout << "3. Exit Program" << endl;

	// user inputs an option based on what they want to do.
	cin >> userOption;

	// 1 clears the menu off, then starts the game.
	if (userOption == 1){

		system("cls");
		cout << "Welcome to Left/Center/Right" << endl;
		system("pause");

		cout << "In order to play, you need three players" << endl;
		cout << "What is Player One's name?" << endl;
		cin >> player1_name;

		cout << "and player two?" << endl;
		cin >> player2_name;

		cout << "Finally, player three?" << endl;
		cin >> player3_name;

		cout << "Welcome " << player1_name << ", " << player2_name << " and," << player3_name << " ! Let us begin playing LCR!" << endl;
		system("pause");

		// begin each round
		if (winner = 0)
		{
			system("cls");
			round++;
			cout << "Welcome to round " << round << endl;
			playerTurn = 1;
			system("pause");
			if (playerTurn == 1, player1_Chips > 0)
			{
				do{
					system("cls");
					cout << "it is currently " << player1_name << "'s turn! Roll your dice!" << endl;
					system("pause");
					roll = (rand() % 6) + 1;

					if (roll == 1)
					{
						cout << player1_name << " has rolled an L! " << player2_name << " gets a chip!" << endl;
					}

					if (roll == 3)
					{
						player1_Chips--;
						pot_Chips++;

						cout << player1_name << " has rolled an C, the pot gets a chip! " << endl;
					}
					if (roll == 6)
					{
						cout << player1_name << " has rolled an R! " << player3_name << " gets a chip!" << endl;
						player1_Chips--;
						player3_Chips++;
					}

					else
					{
						cout << "You have rolled " << roll << " ,your turn has ended" << endl;
					};
					break;
				} while (playerTurn == 1, player1_Chips > 0);
			}
			else (player1_Chips > 1;)
			{
				cout << player1_name << "Has no chips! Skipping turn!"
					playerTurn = 2;
			}
			};
			return 0;
		};
	}


	// 2 loads the rules
	if (userOption == 2){
		char chars;
		ifstream stream;

		stream.open("text.txt");
		stream.get(chars);

		while (!stream.eof())
		{
			cout << chars;
			stream.get(chars);
		}
		system("pause");
	};

	// 3 closes the game
	if (userOption == 3)
	{
		system("cls");
		cout << "Exiting program..." << endl;
		system("pause");
		exit(3);
		return 0;
	}
}

Last edited on
You can't use the comma operator to chain multiple conditions you want to check. Instead use && or || depending on what you want.
http://www.cplusplus.com/doc/tutorial/operators/#logical
Topic archived. No new replies allowed.