123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include "olok.h"
- Olok::Olok()
- {
- clear();
- }
- void Olok::clear()
- {
- // clear the grid to be rebuilt as empty
- grid.clear();
- // make 11 boxes for each colored row (not the white ones)
- for(int j = 0; j<white1; j++)
- {
- RowColor empty;
- grid.push_back(empty);
- for (int i = 0; i<CHECKBOXES; i++)
- {
- grid[j].row.push_back(false);
- }
- }
- // clear penalty count
- penaltyCount = 0;
- }
- // get checked off box count for a specific color
- int Olok::getXCount(int color)
- {
- return grid[color].xCount;
- }
- // add checked off box to a specific index on a color
- void Olok::addX(int color, int index)
- {
- grid[color].row[index] = true;
- grid[color].lastIndex = index;
- }
- // check for last value of index
- int Olok::getLastIndex(int color)
- {
- return grid[color].lastIndex;
- }
- // add any Xs from input Olok into this Olok
- void Olok::addOlok(Olok o)
- {
- // find changes in currentTurnOlok and transfer to cumulativeOlok
- for(int j = 0;j <o.grid.size();j++)
- {
- // loop over all Xs in a color
- for(int k = 0;k <o.grid[j].row.size();k++)
- {
- // check for true values in currentTurnOlok's grid
- if(true ==o.grid[j].row[k])
- {
- // transfer true values from currentTurnOlok's grid to cumulativeOlok's grid
- grid[j].row[k] = true;
- }
- }
- }
- // player selects to add penalty, increase the penalty count
- penaltyCount += o.penaltyCount;
- }
- std::string Olok::toString(void) {
- std::string output;
- // check each row on the grid on the scoresheet
- for(int j = 0; j < grid.size(); j++)
- {
- // check each box on the row and then store output
- for(int k = 0; k < grid[j].row.size();k++)
- {
- // look at checkbox value, add it to output
- output.push_back(grid[j].row[k] ? 'T' : 'F');
- }
- }
- // add penalty count to output
- output.push_back(penaltyCount + '0');
- }
|