Tile calculateTile( const Tile origin, const Tile direction ) { return (isLeft(origin) && isLeft(direction) || isRight(origin) && isRight(direction) || isTopRow(origin) && isTopRow(direction) || isBottomRow(origin) && isBottomRow(direction)) ? eTile_Count : static_cast<Tile>(origin + (direction - eTile_Origin)); }
bool Board::findVerticalMatches( int a, std::vector<int>& matches ) { bool result = false; // Look for vertical matches int matching = 0; int currentPos = a; // Down if (!isBottomRow(a)) { while(currentPos < m_board.size() - m_columns) { currentPos += m_columns; if (m_board[currentPos] == m_board[a]) { ++matching; matches.push_back(currentPos); } else { break; } } } // Up currentPos = a; if (!isTopRow(a)) { while(currentPos >= m_columns) { currentPos -= m_columns; if (m_board[currentPos] == m_board[a]) { ++matching; matches.push_back(currentPos); } else { break; } } } if (matching >= 2) { result = true; } return result; }