Help with Yahtzee! (Object in loop)

Hi!

Im having some problem with the yahtzee game im making. Here's the part of the code where the problem is:

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
void gFlow::start()
{
	IOyatzy startIO;
	pointPost startPost;
	YatzyRules startRules;
	gFlow startFlow;

	startIO.setText("Välkommen till Yatzy!");
	startIO.setEndl();
	startIO.setEndl();
	startIO.setText("Hur många spelare (1+)?");
	int howMany = startIO.inputNr();
	nrOfPlay.resize(howMany);

	for (int s = 1; s <= 15; s++)
	{
		startIO.setText("Vill du slå tärningarna (s) eller avsluta (a)?");
		string hitOrQuit = startIO.inputText();
		
		if (hitOrQuit == "a")
		{
			break;
		}
		else
		{
			for (unsigned int i = 0; i < nrOfPlay.size(); i++)
			{
				startIO.setText("Spelare nr");
				startIO.setNr(i+1);
				nrOfPlay[i].theGame(startIO, startPost, startRules, startFlow);
			}
		}
	
	}
}


Now the problem is the vector nrOfPlay. It's a vector of objects representing the number of players. The inner for-loop represent the players turns, first iteration first player, second iteration second player ect. The outer loop represents the number of turns, 15. When all players has made their dice rolls and got their points (this is made in theGame function) in the first turn it's time for second turn. My problem is that the points from the first turn is not saved for the second turn.

So does anyone know why this happens and what to do about it? Problem seem to be the objects in nrOfPlay "reset". They don't "remember" the values they got last turn.
Topic archived. No new replies allowed.