本文整理汇总了C++中Fleet::getAttack方法的典型用法代码示例。如果您正苦于以下问题:C++ Fleet::getAttack方法的具体用法?C++ Fleet::getAttack怎么用?C++ Fleet::getAttack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fleet
的用法示例。
在下文中一共展示了Fleet::getAttack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doOrder
bool Bombard::doOrder(IGObject *fleet) {
Game *game = Game::getGame();
ObjectManager *om = game->getObjectManager();
ObjectTypeManager *odm = game->getObjectTypeManager();
Random *rand = game->getRandom();
IGObject *planetObj = om->getObject(planet->getObjectId());
if(planetObj->getType() != odm->getObjectTypeByName("Planet"))
{
Logger::getLogger()->debug("Player tried to bombard something illogical");
return true;
}
Fleet *fleetData = dynamic_cast<Fleet*>(fleet->getObjectBehaviour());
Planet *planetData = dynamic_cast<Planet*>(planetObj->getObjectBehaviour());
char planetShipTech = PlayerInfo::getPlayerInfo(planetData->getOwner()).getShipTechLevel();
double attack = fleetData->getAttack();
planetData->removeResource("Industry",
static_cast<uint32_t>(attack * INDUSTRY_DMG * (1+rand->getInRange(-2,2)/100.) ));
planetData->removeResource("Social Environment",
static_cast<uint32_t>(attack * SOCIAL_DMG * (1+rand->getInRange(-2,2)/100.) ));
planetData->removeResource("Planetary Environment",
static_cast<uint32_t>(attack * PLANETARY_DMG * (1+rand->getInRange(-2,2)/100.) ));
planetData->removeResource(string("PDB") + planetShipTech,
static_cast<uint32_t>(attack * PDB_DMG / 10. * (1+rand->getInRange(-2,2)/100.) ));
PlayerInfo::getPlayerInfo(fleetData->getOwner()).addVictoryPoints(VICTORY_POINTS);
// PDBs counter-attack at: PDB level * 6 * numPDBs
fleetData->takeDamage( (planetShipTech - '0') *
6 * planetData->getResource(string("PDB") + planetShipTech).first);
Message *msg = new Message();
msg->setSubject("Bombard complete");
string body = "Fleet \"" + fleet->getName() + "\" bombarded " + planetObj->getName();
msg->setBody(PlayerInfo::appAllVictoryPoints(body));
msg->addReference(rst_Action_Order, rsorav_Completion);
msg->addReference(rst_Object, fleet->getID());
msg->addReference(rst_Object, planetObj->getID());
game->getPlayerManager()->getPlayer(fleetData->getOwner())->postToBoard(msg);
game->getPlayerManager()->getPlayer(planetData->getOwner())->postToBoard(msg);
return true;
}