// remove lower line in game field // return true if there are still tiles that can be dropped down // in contest const bool GameField::removeLowerLine(const bool contest) { #ifdef DEBUG std::cout << "GameField::removeLowerLine(" << contest << ")" << std::endl; #endif bool ok = false; // create array with lower line ScoredTileArray tArray; ScoredTile sTile( FieldPos(0, 0), 10, ScoredTile::FIELDDIRECTION_RIGHT, m_field[0][0], 0 ); tArray.push_back(sTile); // remove tiles removeTiles(tArray); // let all existing tiles fall to the ground ok = fallTilesToGround(contest); // and fill with new ones fillEmptyTiles(); // clear array again tArray.clear(); return ok; }
// search for equal tiles in columns // return true if something has been found const bool GameField::findSameTilesInColumns(ScoredTileArray& tArray) const { bool found = false; // we will go through each column for ( unsigned int i = 0; i < FIELD_WIDTH; i++ ) { // reset length unsigned int length = 0; unsigned int bombValue = 0; for ( unsigned int j = 0; j < FIELD_HEIGHT; j++ ) { if ( 0 == j || m_field[i][j] == m_field[i][j-1] ) { // same tile as before or new start tile length++; // check if bomb and add bomb value if ( m_field[i][j].isBomb() ) { bombValue += m_field[i][j].getBombValue(); } // if the last tile in this column // we must check the length if ( FIELD_HEIGHT-1 == j && length >= 3 ) { // only store tiles if length is >= 3 ScoredTile sTile( FieldPos(i, j-length+1), length, ScoredTile::FIELDDIRECTION_UP, m_field[i][j], bombValue ); tArray.push_back(sTile); found = true; //std::cout << "GameField::findSameTilesInColumns1() " //<< i << " " //<< j-length+1 << " " //<< length << " " //<< (char)m_field[i][j].getType() << " " //<< bombValue //<< std::endl; } } else { // new tile here if ( length >= 3 ) { // only store tiles if length is >= 3 ScoredTile sTile( FieldPos(i, j-length), length, ScoredTile::FIELDDIRECTION_UP, m_field[i][j-1], bombValue ); tArray.push_back(sTile); found = true; //std::cout << "GameField::findSameTilesInColumns2() " //<< i << " " //<< j-length << " " //<< length << " " //<< (char)m_field[i][j-1].getType() << " " //<< bombValue //<< std::endl; } // set new length length = 1; bombValue = 0; // check if bomb and add bomb value if ( m_field[i][j].isBomb() ) { bombValue += m_field[i][j].getBombValue(); } } } } return found; }