| 127 | } |
| 128 | |
| 129 | bool Tile::isWallClaimable(Seat* seat) |
| 130 | { |
| 131 | if (getFullness() <= 0.0) |
| 132 | return false; |
| 133 | |
| 134 | if (mType == TileType::lava || mType == TileType::water || mType == TileType::rock || mType == TileType::gold) |
| 135 | return false; |
| 136 | |
| 137 | // Check whether at least one neighbor is a claimed ground tile of the given seat |
| 138 | // which is a condition to permit claiming the given wall tile. |
| 139 | bool foundClaimedGroundTile = false; |
| 140 | for (Tile* tile : mNeighbors) |
| 141 | { |
| 142 | if (tile->getFullness() > 0.0) |
| 143 | continue; |
| 144 | |
| 145 | if (!tile->isClaimedForSeat(seat)) |
| 146 | continue; |
| 147 | |
| 148 | foundClaimedGroundTile = true; |
| 149 | break; |
| 150 | } |
| 151 | |
| 152 | if (foundClaimedGroundTile == false) |
| 153 | return false; |
| 154 | |
| 155 | // If the tile is not claimed, it is claimable |
| 156 | if (!isClaimed()) |
| 157 | return true; |
| 158 | |
| 159 | // We check if the tile is already claimed for our seat |
| 160 | if (isClaimedForSeat(seat)) |
| 161 | return false; |
| 162 | |
| 163 | // The tile is claimed by another team. We check if there is a claimed ground tile |
| 164 | // claimed by the same team. If not, we can claim. If yes, we cannot |
| 165 | Seat* tileSeat = getSeat(); |
| 166 | if (tileSeat == nullptr) |
| 167 | return true; |
| 168 | |
| 169 | foundClaimedGroundTile = false; |
| 170 | for (Tile* tile : mNeighbors) |
| 171 | { |
| 172 | if (tile->getFullness() > 0.0) |
| 173 | continue; |
| 174 | |
| 175 | if (!tile->isClaimedForSeat(tileSeat)) |
| 176 | continue; |
| 177 | |
| 178 | foundClaimedGroundTile = true; |
| 179 | break; |
| 180 | } |
| 181 | |
| 182 | if (foundClaimedGroundTile) |
| 183 | return false; |
| 184 | |
| 185 | return true; |
| 186 | } |
no test coverage detected