#include "game.h" Game::Game() { // initialize the number of columns that each "color" will contain lastColumnIndex = CHECKBOXES - 1; // set up lockOut for(int i = 0; i pointsGuide = {0,1,3,6,10,15,21,28,36,45,55,66,78}; // check players' card for marked boxes for(int i = 0;i 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 } /* 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 if(player != activePlayer) { // if the move equals the sum of the two white die return true, if not return false return turn.moves[0].index == dice.dice[white1] + dice.dice[white2]; } // otherwise this is the active player else { // if one move if(1 == turn.numberOfMoves) { // check sum of white die if(turn.moves[0].index != (dice.dice[white1] + dice.dice[white2])) { int c = turn.moves[1].color; // if any white die plus the colored die equals the move if(turn.moves[1].index == (dice.dice[white1] + dice.dice[c]) || turn.moves[1].index == (dice.dice[white2] + dice.dice[c])) { return true; } // colored die plus either white die was not a move else {return false;} } // otherwise the white sum die was a move else {return true;} } // if two moves else if(2 == turn.numberOfMoves) { // check first input with white die sum if(turn.moves[0].index != (dice.dice[white1] + dice.dice[white2])) { // white die sum was not a move return false; } else { int c = turn.moves[1].color; // check to see if color die + either white die sum equals a move if(turn.moves[1].index == (dice.dice[white1] + dice.dice[c]) || turn.moves[1].index == (dice.dice[white2] + dice.dice[c])) { return true; } else {return false;} } } } }; bool Game::lockOutRule(int player, Turn turn) { // if the player has selected the last column, check it for(int i = 0; i players[player].cumulativeOlok.getXCount(turn.moves[i].color) { fprintf(stdout, "Player[%d] %s tried to check off column 12 without minimum X\n", player, players[player].savedName); return false; } } return true; } bool Game::leftToRightRule(int player, Turn turn) { for(int i = 0; i turn.moves[i].index) { fprintf(stdout,"Player[%d] %s not following left to right rule X\n", player, players[player].savedName); return false; } } return true; } bool Game::checkTurn (int player, Turn turn) { // check all rules for turn verification return lockOutRule( player, turn) && leftToRightRule( player, turn) && isMoveRepresentedInDie(player, turn); } void Game::addX(int player, int color, int index) { }