//print out each spaces current players on that space, centered and ending with a | void Game_Board::printRowWithCurrentPlayers(int numSpaces, int firstSpace, bool isReverse){ int padding = SPACE_WIDTH -2; std::stringstream ss; //run in regular order if not printing in reverse if(!isReverse){ for(int i = 0; i < numSpaces; i++){ Space current = spaces[firstSpace + i]; //gets current space std::string result = current.playersOnSpaceToString(); std::cout << "|" << std::left << std::setw(padding) << centerString(result); } std::cout << "|" << std::endl; // right side ending bracket //else print the spaces as if in reverse order }else{ for(int i = 0; i < numSpaces; i++){ Space current = spaces[firstSpace - i]; //gets current space std::string result = current.playersOnSpaceToString(); //gets current players on the space std::cout << "|" << std::left << std::setw(padding) << centerString(result); } std::cout << "|" << std::endl; // right side ending bracket } }
//Prints middle row with two spaces on either edge of the baord //those spaces are in spaces[space1Index] and spaces[space2Index] void Game_Board::printMiddleRow(int space1Index, int space2Index){ //print out each spaces name, centered and ending with a | int padding = SPACE_WIDTH-2; for(int i = 0; i < SPACES_IN_ROW; i++){ if(i == 0){ Space current = spaces[space1Index]; std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName()) << "|"; } else if(i == 10){ Space current = spaces[space2Index]; std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName()) << "|"; }else{ int x = 1; if(i == 9) x = 2; for(int j = 0; j < SPACE_WIDTH - x; j++){ std::cout << " "; } } } std::cout << std::endl; // right side ending bracket //print out each spaces Owner, centered and ending with a | for(int i = 0; i < SPACES_IN_ROW; i++){ if(i == 0){ Space current = spaces[space1Index]; if(current.isOwnable()){ std::string owner = current.getOwner(); std::string ownerLine = "Owner: " + owner; std::cout << "|" << std::left << std::setw(padding) << centerString(ownerLine) << "|"; }else{ std::cout << "|"; for(int j = 0; j < SPACE_WIDTH - 2; j++){ std::cout << " "; } std::cout << "|"; } } else if(i == 10){ Space current = spaces[space2Index]; if(current.isOwnable()){ std::string owner = current.getOwner(); std::string ownerLine = "Owner: " + owner; std::cout << "|" << std::left << std::setw(padding) << centerString(ownerLine) << "|"; } else{ std::cout << "|"; for(int j = 0; j < SPACE_WIDTH - 2; j++){ std::cout << " "; } std::cout << "|"; } }else{ int x = 1; if(i == 9) x = 2; for(int j = 0; j < SPACE_WIDTH - x; j++){ std::cout << " "; } } } std::cout << std::endl; for(int i = 0; i < SPACES_IN_ROW; i++){ if(i == 0 || i == 10){ std::cout << "|"; for(int j = 0; j < SPACE_WIDTH-2; j++){ std::cout << " "; } std::cout << "|"; }else{ int x = 1; if(i == 9) x = 2; for(int j = 0; j < SPACE_WIDTH - x; j++){ std::cout << " "; } } } std::cout << std::endl; //Prints out the players currently on each space for(int i = 0; i < SPACES_IN_ROW; i++){ if(i == 0){ Space current = spaces[space1Index]; std::string result = current.playersOnSpaceToString(); std::cout << "|" << std::left << std::setw(padding) << centerString(result) << "|"; } else if(i == 10){ Space current = spaces[space2Index]; std::string result = current.playersOnSpaceToString(); std::cout << "|" << std::left << std::setw(padding) << centerString(result) << "|"; }else{ int x = 1; if(i == 9) x = 2; for(int j = 0; j < SPACE_WIDTH - x; j++){ std::cout << " "; } } } std::cout << std::endl; }