本文整理汇总了C++中shared_ptr::AddBuildingCard方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::AddBuildingCard方法的具体用法?C++ shared_ptr::AddBuildingCard怎么用?C++ shared_ptr::AddBuildingCard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::AddBuildingCard方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UseAbility
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!");
}
}
}
}
}