#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, CollectionOfMoves collectionOfMoves) { // 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 (collectionOfMoves.white.index == (dice.dice[white1] + dice.dice[white2])) ? true : false; } // otherwise this is the active player else { // if one move if(1 == collectionOfMoves.numberOfMoves) { // check sum of white die if(collectionOfMoves.white.index != (dice.dice[white1] + dice.dice[white2])) { int c = collectionOfMoves.color.color; // 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])) { 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 move else if(2 == collectionOfMoves.numberOfMoves) { // check first input with white die sum if(collectionOfMoves.white.index != (dice.dice[white1] + dice.dice[white2])) { // white die sum was not a move return false; } else { int c = collectionOfMoves.color.color; // 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])) { return true; } else {return false;} } } } }; void Game::lockOutRule(int player, int color, int index) { // player can add an x to olok in last column if there are 5 x if(lastColumnIndex == index) { if(LOCKOUT_QUALIFIER >= players[player].cumulativeOlok.getXCount(color)) { players[player].currentTurnOlok.addX(color, index); } else{fprintf(stdout, "Player[%d] %s tried to check off column 12 without minimum X\n", player, players[player].savedName);} } } void Game::leftToRightRule(int player, int color, int index) { // player must add an x to olok from left to right if(players[player].cumulativeOlok.getLastIndex(color) > index) { fprintf(stdout,"Player[%d] %s not following left to right rule X\n", player, players[player].savedName); } else{players[player].currentTurnOlok.addX(color, index);} } void Game::addX(int player, int color, int index) { }