|
@@ -65,7 +65,7 @@ void Game::score()
|
|
state = FINISHED;
|
|
state = FINISHED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-void Game::turn(ScoreSheet activePlayer)
|
|
|
|
|
|
+void Game::round()
|
|
{
|
|
{
|
|
// start all players' turns
|
|
// start all players' turns
|
|
for(int i = 0; i <players.size();i++)
|
|
for(int i = 0; i <players.size();i++)
|
|
@@ -185,26 +185,26 @@ void Game::receive(std::string userInput)
|
|
* //
|
|
* //
|
|
*/
|
|
*/
|
|
|
|
|
|
-bool Game::isMoveRepresentedInDie(int player, CollectionOfMoves collectionOfMoves)
|
|
|
|
|
|
+bool Game::isMoveRepresentedInDie(int player, Turn turn)
|
|
{
|
|
{
|
|
// is this the non-active player
|
|
// is this the non-active player
|
|
if(player != activePlayer)
|
|
if(player != activePlayer)
|
|
{
|
|
{
|
|
// if the move equals the sum of the two white die return true, if not return false
|
|
// if the move equals the sum of the two white die return true, if not return false
|
|
- return collectionOfMoves.white.index == dice.dice[white1] + dice.dice[white2];
|
|
|
|
|
|
+ return turn.moves[0].index == dice.dice[white1] + dice.dice[white2];
|
|
}
|
|
}
|
|
// otherwise this is the active player
|
|
// otherwise this is the active player
|
|
else
|
|
else
|
|
{
|
|
{
|
|
// if one move
|
|
// if one move
|
|
- if(1 == collectionOfMoves.numberOfMoves)
|
|
|
|
|
|
+ if(1 == turn.numberOfMoves)
|
|
{
|
|
{
|
|
// check sum of white die
|
|
// check sum of white die
|
|
- if(collectionOfMoves.white.index != (dice.dice[white1] + dice.dice[white2]))
|
|
|
|
|
|
+ if(turn.moves[0].index != (dice.dice[white1] + dice.dice[white2]))
|
|
{
|
|
{
|
|
- int c = collectionOfMoves.color.color;
|
|
|
|
|
|
+ int c = turn.moves[1].color;
|
|
// if any white die plus the colored die equals the move
|
|
// if any white die plus the colored die equals the move
|
|
- if(collectionOfMoves.color.index == (dice.dice[white1] + dice.dice[c]) || collectionOfMoves.color.index == (dice.dice[white2] + dice.dice[c]))
|
|
|
|
|
|
+ if(turn.moves[1].index == (dice.dice[white1] + dice.dice[c]) || turn.moves[1].index == (dice.dice[white2] + dice.dice[c]))
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -214,20 +214,20 @@ bool Game::isMoveRepresentedInDie(int player, CollectionOfMoves collectionOfMove
|
|
// otherwise the white sum die was a move
|
|
// otherwise the white sum die was a move
|
|
else {return true;}
|
|
else {return true;}
|
|
}
|
|
}
|
|
- // if two move
|
|
|
|
- else if(2 == collectionOfMoves.numberOfMoves)
|
|
|
|
|
|
+ // if two moves
|
|
|
|
+ else if(2 == turn.numberOfMoves)
|
|
{
|
|
{
|
|
// check first input with white die sum
|
|
// check first input with white die sum
|
|
- if(collectionOfMoves.white.index != (dice.dice[white1] + dice.dice[white2]))
|
|
|
|
|
|
+ if(turn.moves[0].index != (dice.dice[white1] + dice.dice[white2]))
|
|
{
|
|
{
|
|
// white die sum was not a move
|
|
// white die sum was not a move
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- int c = collectionOfMoves.color.color;
|
|
|
|
|
|
+ int c = turn.moves[1].color;
|
|
// check to see if color die + either white die sum equals a move
|
|
// check to see if color die + either white die sum equals a move
|
|
- if(collectionOfMoves.color.index == (dice.dice[white1] + dice.dice[c]) || collectionOfMoves.color.index == (dice.dice[white2] + dice.dice[c]))
|
|
|
|
|
|
+ if(turn.moves[1].index == (dice.dice[white1] + dice.dice[c]) || turn.moves[1].index == (dice.dice[white2] + dice.dice[c]))
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -238,26 +238,19 @@ bool Game::isMoveRepresentedInDie(int player, CollectionOfMoves collectionOfMove
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-void Game::lockOutRule(int player, int color, int index)
|
|
|
|
|
|
+bool Game::lockOutRule(int player, Turn turn)
|
|
{
|
|
{
|
|
- // player can add an x to olok in last column if there are 5 x
|
|
|
|
- if(lastColumnIndex == index)
|
|
|
|
|
|
+ // if the player has selected the last column, check it
|
|
|
|
+ for(int i = 0; i<turn.moves.size(); i++)
|
|
{
|
|
{
|
|
- if(LOCKOUT_QUALIFIER >= players[player].cumulativeOlok.getXCount(color))
|
|
|
|
|
|
+ // player can take their move in the last column if there are 5 recorded moves in that color
|
|
|
|
+ if(LOCKOUT_QUALIFIER > players[player].cumulativeOlok.getXCount(turn.moves[i].color)
|
|
{
|
|
{
|
|
- players[player].currentTurnOlok.addX(color, index);
|
|
|
|
|
|
+ fprintf(stdout, "Player[%d] %s tried to check off column 12 without minimum X\n", player, players[player].savedName);
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- else{fprintf(stdout, "Player[%d] %s tried to check off column 12 without minimum X\n", player, players[player].savedName);}
|
|
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
void Game::leftToRightRule(int player, int color, int index)
|
|
void Game::leftToRightRule(int player, int color, int index)
|