// //---------------------------------------------------------- // // ReevaluateHoldings() // // called to re-evaluate the suit after a card has been played // void CCombinedSuitHoldings::ReevaluateHoldings(const CCard* pCard) { // first call base class CSuitHoldings::ReevaluateHoldings(pCard); // then for the members m_declarerCards.ReevaluateHoldings(pCard); m_dummyCards.ReevaluateHoldings(pCard); // and re-count CountPoints(TRUE); }
int WordController::SolidTest(Field board[15][15], vector <Letter*>* existLetters, Word * word) { Word * tempWord = new Word(); int totalPoints = 0; bool good = false; for (int i = 0; i < word->letters.size(); i++) { int pos_x = word->letters[i]->getPositionX(); int pos_y = word->letters[i]->getPositionY(); Letter * temp = GetLetterOnBoard(board, existLetters, GetField(board, existLetters, pos_x + 40, pos_y)); Letter * temp2 = GetLetterOnBoard(board, existLetters, GetField(board, existLetters, pos_x - 40, pos_y)); Letter * temp3 = GetLetterOnBoard(board, existLetters, GetField(board, existLetters, pos_x, pos_y + 40)); Letter * temp4 = GetLetterOnBoard(board, existLetters, GetField(board, existLetters, pos_x, pos_y - 40)); // Sprawdzamy czy litera ma jakis sasiadow if (temp == nullptr && temp2 == nullptr && temp3 == nullptr && temp4 == nullptr) { std::string excep = "Alone Letter"; throw excep; } // Jezeli jednak cos wystepuje kolo tej litery i nie jest to litera z tego slowa if ((temp != nullptr && !CheckIfLetterExist(word, temp)) || (temp2 != nullptr && !CheckIfLetterExist(word, temp2)) || (temp3 != nullptr && !CheckIfLetterExist(word, temp3)) || (temp4 != nullptr && !CheckIfLetterExist(word, temp4))) { good = true; } } if (!good) { std::string excep = "Slowo nie laczy sie z juz istniejacym"; throw excep; } if (horizontal) { for (int i = 0; i < word->letters.size(); i++) { int pos_x = word->letters[i]->getPositionX(); int pos_y = word->letters[i]->getPositionY(); Field * begin = GetField(board, existLetters, pos_x, pos_y); tempWord = CheckVertical(board, existLetters, GetLetterOnBoard(board, existLetters, begin)); if (tempWord != nullptr) { wordForCheck.push_back(tempWord); } if(tempWord != nullptr) if (tempWord->letters.size() > 1) { cout << "\n PUNKTY: " << CountPoints(board, existLetters, tempWord); totalPoints += CountPoints(board, existLetters, tempWord); } } int pos_x = word->letters[0]->getPositionX(); int pos_y = word->letters[0]->getPositionY(); Field * begin = GetField(board, existLetters, pos_x, pos_y); tempWord = CheckHorizontal(board, existLetters, GetLetterOnBoard(board, existLetters, begin)); if (tempWord != nullptr) { wordForCheck.push_back(tempWord); } if (tempWord != nullptr) if (tempWord->letters.size() > 1) { cout << "\n PUNKTY: " << CountPoints(board, existLetters, tempWord); totalPoints += CountPoints(board, existLetters, tempWord); } } else if (vertical) { for (int i = 0; i < word->letters.size(); i++) { int pos_x = word->letters[i]->getPositionX(); int pos_y = word->letters[i]->getPositionY(); Field * begin = GetField(board, existLetters, pos_x, pos_y); tempWord = CheckHorizontal(board, existLetters, GetLetterOnBoard(board, existLetters, begin)); if (tempWord != nullptr) { wordForCheck.push_back(tempWord); } if (tempWord != nullptr) if (tempWord->letters.size() > 1) { cout << "\n PUNKTY: " << CountPoints(board, existLetters, tempWord); totalPoints += CountPoints(board, existLetters, tempWord); } } int pos_x = word->letters[0]->getPositionX(); int pos_y = word->letters[0]->getPositionY(); Field * begin = GetField(board, existLetters, pos_x, pos_y); tempWord = CheckVertical(board, existLetters, GetLetterOnBoard(board, existLetters, begin)); if (tempWord != nullptr) { wordForCheck.push_back(tempWord); } if (tempWord != nullptr) if (tempWord->letters.size() > 1) { cout << "\n PUNKTY: " << CountPoints(board, existLetters, tempWord); totalPoints += CountPoints(board, existLetters, tempWord); } } else //Czyli w przypadku gdy dostawiamy pojednycza literke { int pos_x = word->letters[0]->getPositionX(); int pos_y = word->letters[0]->getPositionY(); Field * begin = GetField(board, existLetters, pos_x, pos_y); tempWord = CheckVertical(board, existLetters, GetLetterOnBoard(board, existLetters, begin)); if (tempWord != nullptr) { wordForCheck.push_back(tempWord); } if (tempWord != nullptr) if (tempWord->letters.size() > 1) { cout << "\n PUNKTY: " << CountPoints(board, existLetters, tempWord); totalPoints += CountPoints(board, existLetters, tempWord); } tempWord = CheckHorizontal(board, existLetters, GetLetterOnBoard(board, existLetters, begin)); if (tempWord != nullptr) { wordForCheck.push_back(tempWord); } if (tempWord != nullptr) if (tempWord->letters.size() > 1) { cout << "\n PUNKTY: " << CountPoints(board, existLetters, tempWord); totalPoints += CountPoints(board, existLetters, tempWord); } } //delete tempWord; return totalPoints; }