Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Board.h"
- //================================================================
- //===========================PRIVATE==============================
- //================================================================
- //AUXILIARY MEMBER FUNCTIONS
- //================================================================
- // Set text color
- void Board::setcolor(unsigned int color)
- {
- HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hcon, color);
- }
- // Set text color & background
- void Board::setcolor(unsigned int color, unsigned int background_color) {
- #define BLACK 0
- #define LIGHTGRAY 7
- #define LIGHTRED 12
- HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
- if (background_color == BLACK)
- SetConsoleTextAttribute(hCon, color);
- else
- SetConsoleTextAttribute(hCon, color | BACKGROUND_BLUE | BACKGROUND_GREEN |
- BACKGROUND_RED);
- }
- //Checks if a file exists/can be opened
- bool Board::file_exists(string filename)
- {
- if (ifstream(filename))
- {
- return true;
- }
- return false;
- }
- // Sets all letters in word to CAPS
- string Board::all_caps(string word) {
- for (size_t i = 0; i < word.size(); i++)
- word[i] = toupper(word[i]);
- return word;
- }
- //Checks if line has SPACES
- bool Board::pound_line(string line)
- {
- return (any_of(line.begin(), line.end(), [](char c) {return c == '#'; }));
- }
- //RETURNS WETHER OT NOT THE BOARD IS FULL
- bool Board::full_board() {
- for (vector<char> column : m_board)
- for (char tile : column)
- {
- if (tile == '.')
- return false;
- }
- return true;
- }
- //================================================================
- //===========================PUBLIC===============================
- //================================================================
- //PUZZLE DATA MEMBER FUNCTIONS
- //================================================================
- //Stores contents of puzzle in a file
- void Board::storeBoard(string dictionary_file, bool resuming, string board_file_name) {
- ofstream board_file;
- if (!resuming) {
- unsigned int b;
- ostringstream board_number;
- ifstream IN_boardNumberFile("Board Number.txt");
- IN_boardNumberFile >> b;
- b++;
- IN_boardNumberFile.close();
- ofstream OUT_boardNumberFile("Board Number.txt");
- OUT_boardNumberFile << b;
- OUT_boardNumberFile.close();
- board_number.width(3);
- char blanks = board_number.fill('0');
- board_number << b;
- string file_name = 'b' + board_number.str() + ".txt";
- cout << file_name << endl;
- board_file.open(file_name);
- }
- else board_file.open(board_file_name);
- //STORING DATA INTO FILE
- board_file << "Dictionary File:" << endl;
- board_file << dictionary_file << endl;
- board_file << "Board Contents:" << endl;
- int line_size = m_board[0].size();
- int column_size = m_board.size();
- for (int l = 0; l < line_size; l++) // storing the contents of the board in the board_file
- {
- for (int c = 0; c < column_size; c++)
- {
- board_file << setw(3) << m_board[l][c];
- }
- board_file << endl;
- }
- board_file << "Words in board:" << endl;
- // storing all the words currently in the board into the board file along witht their positions in the board
- for (auto synonims_pair = board_words.begin(); synonims_pair != board_words.end(); synonims_pair++) //synonims pair refers to the pair
- {
- board_file << synonims_pair->second << ": " << synonims_pair->first << endl;
- }
- board_file << "End of file" << endl;
- board_file.close();
- m_board.resize(0);
- board_words.erase(board_words.begin(), board_words.end());
- }
- //Downloads the contents of chosen puzzle
- string Board::loadBoard() {
- string file_name; //name of file containing the contents of the chosen board
- cout << "Board File?" << endl;
- cin >> file_name;
- while (cin.fail()
- || (!(file_exists(file_name)))
- )
- {
- if (cin.fail())
- cout << "Invalid type of input!" << endl;
- else cout << "Unable to open given file" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Board File?" << endl;
- cin >> file_name;
- }
- string line;
- string dictionary_file;
- ifstream board_file(file_name);
- unsigned int l = 0;
- bool file_start = false, board_start = false, board_end = false, file_end = false;
- while (getline(board_file, line))
- {
- if ((file_start) && (!(board_start)) && (line != "Board Contents:"))
- dictionary_file = line;
- else if ((board_start) && (!(board_end)) && (line != "Words in board:"))
- {
- m_board.resize(line.length() / 3);
- while(pound_line(line))
- {
- m_board[l].push_back(line[2]);
- line.erase(0, 3);
- }
- l++;
- }
- else if ((board_end) && (!(file_end)) && (line != "End of file"))
- {
- string position = line.substr(0, 3);
- line.erase(0, 5);
- string word = line;
- board_words.insert(pair<string, string>(word, position));
- }
- if (line == "Dictionary File:")
- file_start = true;
- else if (line == "Board Contents:")
- board_start = true;
- else if (line == "Words in board:")
- board_end = true;
- else if (line == "End of file")
- file_end = true;
- }
- return file_name;
- }
- //MAIN MENU MEMBER FUNCTIONS
- //================================================================
- //Creates a new board
- bool Board::board() {
- unsigned int l, c;
- cout << "Board size (lines & columns) ? ";
- cin >> l >> c;
- //Testar se input é valido e nr maior que 0 e menor que 27
- while (cin.fail() || l < 1 || c < 1 || l > 26 || c > 26) {
- cout << "Insert 2 numbers larger than 0 and smaller than 27!" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Board size (lines & columns)? ";
- cin >> l >> c;
- }
- if (l != 0) {
- vector<char> column;
- for (unsigned int i = 1; i < c + 3; i++) {
- column.push_back('.');
- }
- for (unsigned int i = 1; i < l + 3; i++) {
- m_board.push_back(column);
- }
- m_board[0][0] = '#';
- //Fills the first line with '#'
- for (unsigned int c = 1; c < m_board.size(); c++) {
- m_board[0][c] = '#';
- }
- //Fills the last line with '#'
- for (unsigned int c = 1; c < m_board.size(); c++) {
- m_board[m_board[0].size() - 1][c] = '#';
- }
- //Fills the first column with '#'
- for (unsigned int l = 1; l < m_board[0].size(); l++) {
- m_board[l][0] = '#';
- }
- //Fills the last column with '#'
- for (unsigned int l = 1; l < m_board[0].size(); l++) {
- m_board[l][m_board.size() - 1] = '#';
- }
- cout << endl;
- return true;
- }
- return false;
- }
- // Shows the board according to the data in m_board
- void Board::show_board() {
- //Letras minusculas e maiusculas que vao ser usadas para preencher
- int uppers = 65, lowers = 97;
- //Letras minusculas e maiusculas que vao ser usadas para preencher
- for (size_t l = 0; l < m_board[0].size() - 1; l++)
- {
- for (size_t c = 0; c < m_board.size() - 1; c++)
- {
- //First Tile
- if ((l == 0) && (c == 0))
- {
- setcolor(12);
- cout << left << setw(2) << m_board[0][0] << " ";
- }
- //First Line
- else if (l == 0)
- {
- setcolor(12);
- cout << left << setw(2) << (char)lowers++;
- }
- //First Column
- else if (c == 0)
- {
- setcolor(12);
- cout << left << setw(2) << (char)uppers++;
- }
- //Board Contents
- else
- {
- if (m_board[l][c] == '#')
- {
- setcolor(0, 7);
- cout << " ";
- setcolor(7, 0);
- cout << '#';
- }
- else
- {
- setcolor(0, 7);
- cout << right << setw(2) << m_board[l][c];
- }
- }
- }
- //Back to original color
- setcolor(7, 0);
- cout << " " << endl;
- }
- cout << endl;
- }
- //INSERTION AUXILIARY MEMBER FUNCTIONS
- //================================================================
- //Finds vertical exceptions to horizontal "siding"
- bool Board::vertical_exception(Dictionary dictionary, int l, int c) {
- int column_size = m_board.size() - 2;
- string possible_word, possible_word_head, possible_word_tail;
- if (l == 1)
- {
- for (int l_down = l; (isalpha(m_board[l_down][c])); l_down++)
- {
- possible_word.push_back(m_board[l_down][c]);
- }
- }
- else if (l == column_size)
- {
- for (int l_up = l; (isalpha(m_board[l_up][c])); l_up--)
- {
- possible_word.push_back(m_board[l_up][c]);
- }
- reverse(possible_word.begin(), possible_word.end());
- }
- else
- {
- if (!(isalpha(m_board[l - 1][c])))
- {
- for (int l_down = l + 1; (isalpha(m_board[l_down][c])); l_down++)
- {
- possible_word_tail.push_back(m_board[l_down][c]);
- }
- for (int l_up = l; (isalpha(m_board[l_up][c])); l_up--)
- {
- possible_word_head.push_back(m_board[l_up][c]);
- }
- reverse(possible_word_head.begin(), possible_word_head.end());
- possible_word = possible_word_head + possible_word_tail;
- }
- else
- {
- for (int l_down = l; (isalpha(m_board[l_down][c])); l_down++)
- {
- possible_word_tail.push_back(m_board[l_down][c]);
- }
- for (int l_up = l - 1; (isalpha(m_board[l_up][c])); l_up--)
- {
- possible_word_head.push_back(m_board[l_up][c]);
- }
- reverse(possible_word_head.begin(), possible_word_head.end());
- possible_word = possible_word_head + possible_word_tail;
- }
- }
- return (dictionary.word_exists(possible_word));
- }
- //Finds horizontal exceptions to vertical "siding"
- bool Board::horizontal_exception(Dictionary dictionary, int l, int c) {
- int line_size = m_board[0].size() - 2;
- string possible_word, possible_word_head, possible_word_tail;
- if (c == 1)
- {
- for (int c_right = c; (isalpha(m_board[l][c_right])); c_right++)
- {
- possible_word.push_back(m_board[l][c_right]);
- }
- }
- else if (c == line_size)
- {
- for (int c_left = c; (isalpha(m_board[l][c_left])); c_left--)
- {
- possible_word.push_back(m_board[l][c_left]);
- }
- reverse(possible_word.begin(), possible_word.end());
- }
- else
- {
- if (!(isalpha(m_board[l][c - 1])))
- {
- for (int c_right = c + 1; (isalpha(m_board[l][c_right])); c_right++)
- {
- possible_word_tail.push_back(m_board[l][c_right]);
- }
- for (int c_left = c; (isalpha(m_board[l][c_left])); c_left--)
- {
- possible_word_head.push_back(m_board[l][c_left]);
- }
- reverse(possible_word_head.begin(), possible_word_head.end());
- possible_word = possible_word_head + possible_word_tail;
- }
- else
- {
- for (int c_right = c; (isalpha(m_board[l][c_right])); c_right++)
- {
- possible_word_tail.push_back(m_board[l][c_right]);
- }
- for (int c_left = c - 1; (isalpha(m_board[l][c_left])); c_left--)
- {
- possible_word_head.push_back(m_board[l][c_left]);
- }
- reverse(possible_word_head.begin(), possible_word_head.end());
- possible_word = possible_word_head + possible_word_tail;
- }
- }
- return (dictionary.word_exists(possible_word));
- }
- //Returns wether or not word can be placed in position
- bool Board::word_fits(Dictionary dictionary, string position, string word) {
- char line_letter = position[0];
- char column_letter = position[1];
- char direction_letter = position[2];
- int line_size = m_board[0].size() - 2;
- int column_size = m_board.size() - 2;
- size_t initial_line = (int)line_letter - 64;
- size_t initial_column = (int)column_letter - 96;
- size_t l = initial_line;
- size_t c = initial_column;
- //VERTICALLY
- if ((direction_letter == 'V') || (direction_letter == 'v')) {
- //Checking if word limmits don't go beyond the board's lower limits
- if ((initial_line + word.length()) > line_size + 1)
- {
- //cout << "Word would go beyond the board limits" << endl;
- return false;
- }
- if (isalpha(m_board[l - 1][c])) //checking that there isnt anything before the word where the # would be
- {
- //cout << "The tile where the '#' before the word would be isn't empty" << endl;
- return false;
- }
- //Checking if word wouldn't overlap with existing letters and if there wouldn't any letters around it
- for (int i = 0; i < word.length(); l++, i++) {
- //if current board tiles where word letters would be are different from those letters...
- if ((m_board[l][c] != '.') && (m_board[l][c] != word[i]))
- {
- //cout << "There would be an error overlap(different characters for the same tile) of word wih the current tiles of where word would be in the board" << endl;
- return false;
- }
- //Checking if there would be other vertical words siding with our word:
- //Note: there are a few exceptions where this is alright
- //Checking left
- if ((((isalpha(m_board[l - 1][c - 1])) && (isalpha(m_board[l][c - 1]))) || ((isalpha(m_board[l][c - 1])) && (isalpha(m_board[l + 1][c - 1]))))
- && (!(horizontal_exception(dictionary, l, c - 1))))
- {
- //cout << "5There would be another vertical word siding with word on the left" << endl;
- return false;
- }
- //Checking right
- if ((((isalpha(m_board[l - 1][c + 1])) && (isalpha(m_board[l][c + 1]))) || ((isalpha(m_board[l][c + 1])) && (isalpha(m_board[l + 1][c + 1]))))
- && (!(horizontal_exception(dictionary, l, c + 1))))
- {
- //cout << "6There would be another vertical word siding with word on the right" << endl;
- return false;
- }
- }
- if (isalpha(m_board[l][c])) //checking that there isnt anything after the word where the # would be
- {
- //cout << "The tile where the '#' after the word would be isn't empty" << endl;
- return false;
- }
- }
- //HORIZONTALLY
- if ((direction_letter == 'H') || (direction_letter == 'h')) {
- //Checking if word limmits don't go beyond the board's right limits
- if ((initial_column + word.length()) > column_size + 1)
- {
- //cout << "Word would go beyond the board limits" << endl;
- return false;
- }
- if (isalpha(m_board[l][c - 1])) //checking that there isnt anything before the word where the # would be
- {
- //cout << "The tile where the '#' before the word would be isn't empty" << endl;
- return false;
- }
- //Checking if word wouldn't overlap with existing letters and if there wouldn't be any letters around it
- for (int i = 0; i < word.length(); c++, i++) {
- //if tiles where word letters would be are different from those letters...
- if ((m_board[l][c] != '.') && (m_board[l][c] != word[i]))
- {
- //cout << "There would be an error overlap(different characters for the same tile) of word wih the current tiles of where word would be in the board" << endl;
- return false;
- }
- //Checking if there would be other horizontal words siding with our word:
- //Note: there are a few exceptions where this is alright
- //Checking down
- if (((isalpha(m_board[l + 1][c - 1])) && (isalpha(m_board[l + 1][c])) || ((isalpha(m_board[l + 1][c])) && (isalpha(m_board[l + 1][c + 1]))))
- && (!(vertical_exception(dictionary, l + 1, c))))
- {
- //cout << "5There would be another horizontal word siding with word below" << endl;
- return false;
- }
- //Checking up
- if ((((isalpha(m_board[l - 1][c - 1])) && (isalpha(m_board[l - 1][c]))) || ((isalpha(m_board[l - 1][c])) && (isalpha(m_board[l - 1][c + 1]))))
- && (!(vertical_exception(dictionary, l - 1, c))))
- {
- //cout << "6There would be another horizontal word siding with word above" << endl;
- return false;
- }
- }
- if (isalpha(m_board[l][c])) //checking that there aren't any letters after the word where the # would be
- {
- //cout << "The tile where the '#' after the word would be isn't empty" << endl;
- return false;
- }
- }
- return true;
- }
- //Helps the user by showing him/her a list of words that can be added taking into account the current contents of the board
- void Board::help(Dictionary dictionary, string position) {
- cout << "AVAILABLE COMMANDS:" << endl;
- cout << "+ = place word in board" << endl;
- cout << "- = remove word from board" << endl;
- cout << "CTRL-Z = back to main menu" << endl;
- cout << endl;
- //Max of 3 words suggested
- unsigned int suggestion_counter = 0;
- cout << "SOME POSSIBILITIES FOR " << position << ":" << endl;
- cout << endl;
- for (auto it = dictionary.synonims_map.begin(); it != dictionary.synonims_map.end(); it++) {
- if ((board_words.find(it->first) == board_words.end()) && word_fits(dictionary, position, it->first)) {
- cout << "(" << suggestion_counter << ") " << it->first << endl;
- suggestion_counter++;
- }
- if (suggestion_counter == 3)
- break;
- }
- cout << endl;
- }
- //REMOVAL AUXILIARY MEMBER FUNCTIONS
- //================================================================
- void Board::pound_check() {
- m_board[0][0] = '#';
- //Fills the first line with '#'
- for (int c = 1; c < m_board[0].size(); c++) {
- m_board[0][c] = '#';
- }
- //Fills the last line with '#'
- for (int c = 1; c < m_board[0].size(); c++) {
- m_board[m_board.size() - 1][c] = '#';
- }
- //Fills the first column with '#'
- for (int l = 1; l < m_board.size(); l++) {
- m_board[l][0] = '#';
- }
- //Fills the last column with '#'
- for (int l = 1; l < m_board.size(); l++) {
- m_board[l][m_board[0].size() - 1] = '#';
- }
- for (auto it = board_words.begin(); it != board_words.end(); it++) {
- string word = it->first;
- string position = it->second;
- char line_letter = position[0]; //line_letter represents the line where the first letter of the word the user wants to insert in the board will be
- char column_letter = position[1]; //column_letter represents the column where the first letter of the word the user wants to insert in the board will be
- char direction_letter = position[2]; //direction_letter represents the direction in which the word the user wants to insert in the board will be writen
- size_t initial_line = (int)line_letter - 64; //Ex: Se line_letter = 'a' entao initial_line = 1
- size_t initial_column = (int)column_letter - 96; //Ex: Se column_letter = 'A' entao initial_column = 1
- size_t l = initial_line;
- size_t c = initial_column;
- if ((direction_letter == 'V') || (direction_letter == 'v')) {
- m_board[l - 1][c] = '#';
- m_board[l + word.length()][c] = '#';
- }
- if ((direction_letter == 'H') || (direction_letter == 'h')) {
- m_board[l][c - 1] = '#';
- m_board[l][c + word.length()] = '#';
- }
- }
- }
- //ADVANCED MENU MEMBER FUNCTIONS
- //================================================================
- //Inserts a word in board
- void Board::insert_word(Dictionary dictionary)
- {
- //Posititon
- string position;
- cout << "Position (LCD / CTRL-Z = cancel): ";
- cin >> position;
- int line_size = m_board[0].size() - 2;
- int column_size = m_board.size() - 2;
- //Testing if input position is valid
- while (true)
- {
- if ((position.length() == 3
- && (int)position[0] >= 65 && (int)position[0] <= 64 + line_size
- && (int)position[1] >= 97 && (int)position[1] <= 96 + column_size
- && ((position[2] == 'V' || position[2] == 'H')
- || (position[2] == 'v' || position[2] == 'h')))
- || cin.eof())
- break;
- else
- {
- cout << "Introduza duas letras (Maiuscula seguida de Minuscula) que pertencam ao quadro seguida da direcao desejada (V ou H)\n" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Position (LCD / CTRL-Z = cancel) ? ";
- cin >> position;
- }
- }
- if (position.length() > 0) //If the user didn't change his mind
- {
- string word;
- cout << "Word to insert (CTRL-Z = cancel, ? = help): ";
- cin >> word;
- word = all_caps(word);
- //Testing if input word is valid
- while (cin.fail()
- || !(dictionary.word_exists(word))
- || !(word_fits(dictionary, position, word))
- || board_words.find(word) != board_words.end()
- || word != "?"
- || !cin.eof())
- {
- if (cin.fail() && !cin.eof())
- {
- cout << "Invalid Input for Word!" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Word to insert (CTRL-Z = cancel, ? = help): ";
- }
- else if (word == "?")
- {
- help(dictionary, position);
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Word to insert (CTRL-Z = cancel, ? = help): ";
- }
- else if (!(dictionary.word_exists(word)) && !cin.eof())
- {
- cout << "Given word does not exist according to our records" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Please insert a different word: ";
- }
- else if (!(word_fits(dictionary, position, word)) && !cin.eof())
- {
- cout << "Given word cannot be placed in position" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Please insert a different word or alter the board so it fits: ";
- }
- else if (board_words.find(word) != board_words.end()) {
- cout << "Given word is already on board" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Please insert a different word or alter the board so it fits: ";
- }
- else break;
- cin >> word;
- word = all_caps(word);
- }
- if (!cin.eof()) {
- //INSERTING WORD
- char line_letter = position[0]; //line_letter represents the line where the first letter of the word the user wants to insert in the board will be
- char column_letter = position[1]; //column_letter represents the column where the first letter of the word the user wants to insert in the board will be
- char direction_letter = position[2]; //direction_letter represents the direction in which the word the user wants to insert in the board will be writen
- word = all_caps(word);
- size_t initial_line = (int)line_letter - 64; //Ex: Se line_letter = 'a' entao initial_line = 1
- size_t initial_column = (int)column_letter - 96; //Ex: Se column_letter = 'A' entao initial_column = 1
- size_t l = initial_line;
- size_t c = initial_column;
- // Inserts word in board vertically
- if ((direction_letter == 'V') || (direction_letter == 'v')) {
- m_board[l - 1][c] = '#'; //places a # before the word
- for (int i = 0; i < word.length(); i++, l++) {
- m_board[l][c] = word[i];
- }
- m_board[l][c] = '#'; //places a # after the word
- }
- //Inserts word in board horizontally
- if ((direction_letter == 'H') || (direction_letter == 'h')) {
- m_board[l][c - 1] = '#'; //places a # before the word
- for (int i = 0; i < word.length(); i++, c++) {
- m_board[l][c] = word[i];
- }
- m_board[l][c] = '#'; //places a # after the word
- }
- if (word.length() > 0) //If the user didn't change his mind...
- {
- board_words.insert(pair<string, string>(word, position)); //added word to the list of words in the board
- //sera que devia usar emplace em vez de insert?, esta bem feito este pair temporario?
- show_board();
- }
- }
- }
- }
- //Removes a word from board
- void Board::remove_word() {
- string word;
- cout << "Word to remove (CTRL-Z = cancel) ?" << endl;
- cin >> word;
- word = all_caps(word);
- //Testing if input word is on the board
- while (board_words.find(word) == board_words.end()
- || !cin.eof()
- || cin.fail())
- {
- if (cin.eof())
- {
- break;
- }
- else if (cin.fail())
- {
- cout << "Invalid Input for Word!" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Word to remove (CTRL-Z = cancel) ?" << endl;
- }
- else if (board_words.find(word) == board_words.end())
- {
- cout << "There is no such word currently in the board" << endl;
- cin.clear();
- cin.ignore(1000, '\n');
- cout << "Word to remove (CTRL-Z = cancel) ?" << endl;
- }
- else break;
- cin >> word;
- word = all_caps(word);
- }
- if (word.length() > 0) //If the user didn't change his mind...
- {
- map<string, string>::iterator it = board_words.find(word);
- string position = it->second; //tells you the position of the word to be removed
- char line_letter = position[0]; //line_letter represents the line where the first letter of the word the user wants to insert in the board will be
- char column_letter = position[1]; //column_letter represents the column where the first letter of the word the user wants to insert in the board will be
- char direction_letter = position[2]; //direction_letter represents the direction in which the word the user wants to insert in the board will be writen
- size_t initial_line = (int)line_letter - 64; //Ex: If line_letter = 'a' then initial_line = 1
- size_t initial_column = (int)column_letter - 96; //Ex: If column_letter = 'A' then initial_column = 1
- size_t l = initial_line;
- size_t c = initial_column;
- //REMOVING WORD
- //There will be no need to later "restore" words that may have been intercepted with the word removed
- //as we are checking before removing a letter wether or not it is attached to another word
- //Removes word in board vertically
- if ((direction_letter == 'V') || (direction_letter == 'v')) {
- //Resets the (#)tile before the word
- m_board[l - 1][c] = '.';
- for (int i = 0; i < word.length(); i++, l++) {
- if ((!(isalpha(m_board[l][c - 1]))) && (!(isalpha(m_board[l][c + 1]))))
- m_board[l][c] = '.';
- }
- //Resets the (#)tile after the word
- m_board[l][c] = '.';
- }
- //Removes word in board horizontally
- if ((direction_letter == 'H') || (direction_letter == 'h')) {
- //Resets the (#)tile before the word
- m_board[l][c - 1] = '.';
- for (int i = 0; i < word.length(); i++, c++) {
- if ((!(isalpha(m_board[l - 1][c]))) && (!(isalpha(m_board[l + 1][c]))))
- m_board[l][c] = '.';
- }
- //Resets the (#)tile after the word
- m_board[l][c] = '.';
- }
- board_words.erase(board_words.find(word)); // removes word from the list of words that are currently in the board
- pound_check();
- show_board();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement