|
@@ -128,63 +128,34 @@ std::string Game::send()
|
|
|
// " 1143"
|
|
|
// emma's intention is to take a penalty
|
|
|
// "1"
|
|
|
-void Game::receive(std::string userInput)
|
|
|
+// convert a user string into a turn
|
|
|
+struct Turn Game::receive(std::string userInput)
|
|
|
{
|
|
|
players[0].currentTurnOlok.clear();
|
|
|
- // penalties are marked to card if user string = 1
|
|
|
- // did the user send a number?
|
|
|
- // ## Range Check to go into Receive ##
|
|
|
- #ifdef WORKING_ON_RANGE_CHECK
|
|
|
- // if index is too high or too low, throw an error
|
|
|
- if(CHECKBOXES > index || 0 < index){fprintf(stdout,"Player[%d] %s index is too high or too low X\n", player, players[player].savedName);}
|
|
|
- // if color is not valid throw an error
|
|
|
- players[0].cumulativeOlok.isColor(red);
|
|
|
- if(color){fprintf(stdout,"Player[%d] %s invalid color selected X\n", player, players[player].savedName);}
|
|
|
- #endif
|
|
|
- // if a user did not send a number no changes take place
|
|
|
- // take the userinput (string) and parse it into parts
|
|
|
- // what is the length of the userInput? length of 2, 4? (boxes 0-9 are represented as 00,01,02...)
|
|
|
-
|
|
|
- // convert userInput into number
|
|
|
- // user number to change the boolean on corresponding spot on ScoreSheet
|
|
|
+ Turn turn;
|
|
|
+ // userinput is one, add a penalty
|
|
|
+ if(1 == userInput.size())
|
|
|
+ {
|
|
|
+ turn.penalty = 1;
|
|
|
+ }
|
|
|
+ // userinput size is two, add one moves
|
|
|
+ else if(2 == userInput.size())
|
|
|
+ {
|
|
|
+ turn.moves[0] = translateToMove(userInput);
|
|
|
+ turn.numberOfMoves = 1;
|
|
|
+ }
|
|
|
+ // userinput size is four, add two moves
|
|
|
+ else if(4 == userInput.size())
|
|
|
+ {
|
|
|
+ turn.moves[0] = translateToMove(userInput.substr(0,2));
|
|
|
+ turn.moves[1] = translateToMove(userInput.substr(2,2));
|
|
|
+ turn.numberOfMoves = 2;
|
|
|
+ }
|
|
|
+ else {fprintf(stdout, "Form an opinion: WRONG!");}
|
|
|
+ // check the rules to make sure turn is valid
|
|
|
+ // add turn to currentTurnOlok if the turn is valid
|
|
|
}
|
|
|
|
|
|
-/* add a checkbox to a specified players scoresheet user specifies player's: XXXX, the color, and index of the checkbox on the colored row
|
|
|
- * dont know what XXXX is yet - but it will be used to find correct player
|
|
|
- *
|
|
|
- *
|
|
|
- *
|
|
|
- * the white die and color combo must match the corresponding RowColor and index
|
|
|
- *
|
|
|
- */
|
|
|
-
|
|
|
-/*
|
|
|
- * all players can do white die combination, active player can do a colored + white die combination.
|
|
|
- *
|
|
|
- * ## Things we need to know ##
|
|
|
- * sum of both white die
|
|
|
- * sums of 8 dice
|
|
|
- * who is active player
|
|
|
- *
|
|
|
- * ## How to do ##
|
|
|
- * on a given turn, sum the white die and sum each of the white die and all of the colored die
|
|
|
- * check to see if each players' requested move is valid
|
|
|
- * - does their input match the sum of the white die
|
|
|
- * check to see if active player requested move is valid
|
|
|
- * - for the active player check white die sum if one input. if it fails then check each white die + color die sums add item to scoresheet
|
|
|
- * - for the active player if two inputs are passsed, check white die sum first if it passes, add to scoresheet. then check the second input with white die + colored die
|
|
|
- * if it is valid, add it to player card
|
|
|
- * if it is not valid, return an error to player
|
|
|
- *
|
|
|
- * ## players' move
|
|
|
- * // this function has access to diceRoll and player input
|
|
|
- * // is the players' input a valid move <- what does valid mean? (is it represented in die, does it follow left to right, does it follow lockout, does it fit within the confines of a move)
|
|
|
- * // the confines of a move for non-actie player is (0 or one white die move)
|
|
|
- * // the confines of a move for active palyer is (penalty or (one or two die moves))
|
|
|
- *
|
|
|
- * //
|
|
|
- */
|
|
|
-
|
|
|
bool Game::isMoveRepresentedInDie(int player, Turn turn)
|
|
|
{
|
|
|
// is this the non-active player
|
|
@@ -275,4 +246,14 @@ bool Game::checkTurn (int player, Turn turn)
|
|
|
|
|
|
void Game::addX(int player, int color, int index)
|
|
|
{
|
|
|
+}
|
|
|
+struct Move Game::translateToMove(std::string temp)
|
|
|
+{
|
|
|
+ int temp2 = stoi(temp);
|
|
|
+ struct Move newMove;
|
|
|
+ // find the color
|
|
|
+ newMove.color = (temp2/colors);
|
|
|
+ // find the index, subtracted 1 from checkboxes because it is lockout bonus box - only interested in scored boxes
|
|
|
+ newMove.index = (temp2%(CHECKBOXES-1));
|
|
|
+ return newMove;
|
|
|
}
|