40 for(vector<Tile*> word : wordsInPlay) {
42 wordStr.append(t->getLetterStr());
44 wordStr.append(
" + ");
46 if(!wordStr.empty()) {
47 wordStr.replace(wordStr.end()-3, wordStr.end(),
"");
92 int max = tileStr.length();
98 for(
int i = 0; i < max; i++) {
107 ( currLeft && !currLeft->
isEmpty() )
108 || ( currRight && !currRight->
isEmpty() )
109 || ( currAbove && !currAbove->
isEmpty() )
110 || ( currBelow && !currBelow->
isEmpty() );
125 else if(dir ==
'v') {
128 for(
int i = 0; i < max; i++) {
136 ( currLeft && !currLeft->
isEmpty() )
137 || ( currRight && !currRight->
isEmpty() )
138 || ( currAbove && !currAbove->
isEmpty() )
139 || ( currBelow && !currBelow->
isEmpty() );
155 throw(
string(
"Invalid direction\n"));
177 vector<Tile*> placedTiles;
185 currSquare = b->
getSquare(currRow, currCol);
187 currSquare = currSquare->
getLeft();
190 while(currSquare && !currSquare->
isEmpty()) {
191 placedTiles.push_back(currSquare->
getTile());
192 currSquare = currSquare->
getRight();
194 wordsInPlay.push_back(placedTiles);
196 for(
Tile* t : tilesInStr) {
197 currSquare = t->getSquare();
200 wordsInPlay.push_back(getConnectedWord(t,
'v'));
208 else if(dir ==
'v') {
210 currSquare = b->
getSquare(currRow, currCol);
213 currSquare = currSquare->
getAbove();
217 while(currSquare && !currSquare->
isEmpty()) {
218 placedTiles.push_back(currSquare->
getTile());
219 currSquare = currSquare->
getBelow();
221 wordsInPlay.push_back(placedTiles);
223 for(
Tile* t : tilesInStr) {
224 currSquare = t->getSquare();
227 wordsInPlay.push_back(getConnectedWord(t,
'h'));
257 vector<Tile*> connectedWord;
259 if(searchDir ==
'h') {
262 currSquare = currSquare->
getLeft();
265 while(currSquare && !currSquare->
isEmpty()) {
266 connectedWord.push_back(currSquare->
getTile());
267 currSquare = currSquare->
getRight();
270 else if(searchDir ==
'v') {
273 currSquare = currSquare->
getAbove();
276 while(currSquare && !currSquare->
isEmpty()) {
277 connectedWord.push_back(currSquare->
getTile());
278 currSquare = currSquare->
getBelow();
282 throw(
string(
"Invalid direction\n"));
285 return connectedWord;
303 for(vector<Tile*> word : words) {
304 for(
Tile* t : word) {
305 switch(t->getSquare()->getType()) {
307 pointsMade += t->getPoints();
311 pointsMade += 2*(t->getPoints());
315 pointsMade += t->getPoints();
320 pointsMade += 3*(t->getPoints());
323 pointsMade += t->getPoints();
327 pointsMade += t->getPoints();
333 pointsMade += t->getPoints();
341 pointsMade *= multiplier;
Square * getSquare(int r, int c)
void calculatePoints(std::vector< std::vector< Tile * >> words, std::vector< Tile * > tileStrVec)
std::vector< Tile * > getConnectedWord(Tile *t, char dir)
std::vector< std::vector< Tile * > > getWords(std::vector< Tile * > tilesInStr, Board *b, int r, int c, char dir)
bool validate(std::string tileStr, Board *b, int r, int c, char dir)
void setPlayer(Player *p)
bool tilePresent(std::vector< Tile * > t, Tile *target)
void PALE_GREEN_FG(std::string x)
void BOLD_WHITE_FG(std::string x)