void WarlordState::UseAbility(shared_ptr<Player> &player, shared_ptr<Game> &game) { if (game->GetOpponent(player)->GetBuildings()->Size() >= 8) { player->GetClient()->writeline("Your opponent has built 8 or more buildings, you are not allowed to destroy his buildings!"); } else if (game->GetOpponent(player)->HasCharacterCard("Bishop")) { player->GetClient()->writeline("Your opponent has the bishop card, you are not allowed to destroy his buildings!"); } else { // Print opponent cards LookAtOpponent(player, game); player->GetClient()->writeline("Which building do you want to destroy?"); int choice = -1; do { choice = HandleChoice(player, game, player->GetBuildings()->Size() - 1); } while (choice == -1); BuildingCard destroy = game->GetOpponent(player)->GetBuildings()->ShowCardByIndex(choice); if (destroy.GetName() == "Dungeon") player->GetClient()->writeline("A dungeon cannot be destroyed!"); else { if (destroy.GetValue() == 1) game->GetOpponent(player)->DestroyByIndex(choice); else { int cost = destroy.GetValue() - 1; if (player->GetGoldAmount() >= cost) { // Player has enough gold to destroy building player->RemoveGold(cost); game->AddGold(cost); BuildingCard card = game->GetOpponent(player)->GetBuildings()->GetCardByIndex(choice); player->GetClient()->writeline("Building destroyed!"); if (game->GetOpponent(player)->GetGoldAmount() >= 1 && game->GetOpponent(player)->HasBuilding("Graveyard")) { game->GetOpponent(player)->RemoveGold(1); game->AddGold(1); game->GetOpponent(player)->AddBuildingCard(card); game->GetOpponent(player)->GetClient()->writeline("The warlord destoyed your " + card.GetName() + ", card returned to your hand"); } else { game->GetOpponent(player)->GetClient()->writeline("The warlord destoyed your " + card.GetName() + "!"); game->AddBuildingCard(card); } } else { // Not enough gold to destroy this building player->GetClient()->writeline("Not enough gold available to destroy this building!"); } } } } }