bool Board::display() //Displays the board { if (!hasSpinner() && rightRow.size() == 0) return false; if (!hasSpinner()) //if no spinner is in the board { vector<Bone> vecRow = getRow('e'); int numChars = vecRow.size()*4; numChars = 60 - numChars/2; int x = numChars; int y = 27; for (unsigned int i = 0; i < vecRow.size(); i++) { Bone tempBone = vecRow[i]; if (i == 0) tempBone.swap(); tempBone.display(x,y,'e'); } } else //if there is a spinner on the board { int tempX = 60; int tempY = 27; spinner.display(tempX,tempY,'e'); if (rightRow.size() != 0) { int x = 62; int y = 27; bool up = false; bool left = false; bool lastDouble = false; for (unsigned int i = 0; i < rightRow.size(); i++) //the following code accounts for the possibility of the bones coming out of the board's limits { if (x >= 114 && !up) { up = true; if (lastDouble) { y = y - 3; x = x - 2; } else { x = x - 2; y = y - 2; } } if (y <= 8 && !left) { left = true; if (lastDouble) { y = y + 2; x = x - 3; } else { y = y + 2; x = x - 2; } } if (up) if (left) rightRow[i].display(x,y,'w'); else rightRow[i].display(x,y,'n'); else rightRow[i].display(x,y,'e'); if (rightRow[i].isDouble()) lastDouble = true; else lastDouble = false; } } if (leftRow.size() != 0) { int x = 58; int y = 27; bool down = false; bool right = false; bool lastDouble = false; for (unsigned int i = 0; i < leftRow.size(); i++) { if (x <= 4 && !down) { down = true; if (lastDouble) { x = x + 2; y = y + 3; } else { x = x + 2; y = y + 2; } } if (y >= 45 && !right) { right = true; if (lastDouble) { y = y - 2; x = x + 3; } else { y = y - 2; x = x + 2; } } if (down) if (right) leftRow[i].display(x,y,'e'); else leftRow[i].display(x,y,'s'); else leftRow[i].display(x,y,'w'); if (leftRow[i].isDouble()) lastDouble = true; else lastDouble = false; } } if (topRow.size() != 0) { int x = 60; int y = 24; bool left = false; bool down = false; bool lastDouble = false; for (unsigned int i = 0; i < topRow.size(); i++) { if (x <= 20 && !down) { down = true; if (lastDouble) { x = x + 2; y = y + 3; } else { x = x + 2; y = y + 2; } } if (y <= 5 && !left) { left = true; if (lastDouble) { y = y + 2; x = x - 3; } else { y = y + 2; x = x - 2; } } if (left) if (down) topRow[i].display(x,y,'s'); else topRow[i].display(x,y,'w'); else topRow[i].display(x,y,'n'); if (topRow[i].isDouble()) lastDouble = true; else lastDouble = false; } } if (bottomRow.size() != 0) { int x = 60; int y = 30; bool right = false; bool up = false; bool lastDouble = false; for (unsigned int i = 0; i < bottomRow.size(); i++) { if (x >= 114 && !up) { up = true; if (lastDouble) { x = x - 2; y = y - 3; } else { x = x - 2; y = y - 2; } } if (y >= 45 && !right) { right = true; if (lastDouble) { y = y - 2; x = x + 3; } else { y = y - 2; x = x + 2; } } if (right) if (up) bottomRow[i].display(x,y,'n'); else bottomRow[i].display(x,y,'e'); else bottomRow[i].display(x,y,'s'); if (bottomRow[i].isDouble()) lastDouble = true; else lastDouble = false; } } } return true; }