本文整理汇总了C++中IdMap::rend方法的典型用法代码示例。如果您正苦于以下问题:C++ IdMap::rend方法的具体用法?C++ IdMap::rend怎么用?C++ IdMap::rend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdMap
的用法示例。
在下文中一共展示了IdMap::rend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doCombat
void RSPCombat::doCombat(std::map<uint32_t, IdSet> sides) {
Game* game = Game::getGame();
PlayerManager::Ptr playermanager = game->getPlayerManager();
ObjectManager* objectmanager = game->getObjectManager();
DesignStore::Ptr ds = game->getDesignStore();
const char * const rsp[] = {"rock", "scissors", "paper"};
IdSet listallobids;
IdSet listallplayerids;
std::map<uint32_t, std::vector<Combatant*> > fleetcache;
battlelogger.reset(new BattleXML::BattleLogger());
msgstrings.clear();
for(std::map<uint32_t, IdSet>::iterator itmap = sides.begin(); itmap != sides.end(); ++itmap) {
std::vector<Combatant*> pcombatant;
Player::Ptr player = playermanager->getPlayer(itmap->first);
battlelogger->startSide(player->getName());
IdSet theset = itmap->second;
for(IdSet::iterator itset = theset.begin(); itset != theset.end(); ++itset) {
listallobids.insert(*itset);
IGObject::Ptr obj = objectmanager->getObject (*itset);
objectcache[*itset] = obj;
if(obj->getType() == obT_Fleet) {
Fleet* f2 = (Fleet*)(obj->getObjectBehaviour());
IdMap shiplist = f2->getShips();
uint32_t damage = f2->getDamage();
for(IdMap::reverse_iterator itship = shiplist.rbegin(); itship != shiplist.rend(); ++itship) {
for(uint32_t i = 0; i < itship->second; i++) {
Combatant* f1 = new Combatant();
f1->setOwner(itmap->first);
f1->setObject(obj->getID());
f1->setShipType(itship->first);
uint32_t mydamage = damage / std::max(1U, (unsigned int)(shiplist.size() - i));
f1->setDamage(mydamage);
damage -= mydamage;
std::string type = ds->getDesign(itship->first)->getName();
f1->setBattleXmlType(type);
f1->setBattleXmlId(str(boost::format("%1%-%2%-%3%") % type % obj->getID() % i));
f1->setBattleXmlName(str(boost::format("%1%'s %2%, %3% %4%") % player->getName() % obj->getName() % type % i));
battlelogger->addCombatant(f1);
pcombatant.push_back(f1);
}
}
} else {
int shipcount = 2;
int homeplanetid = game->getResourceManager()->getResourceDescription("Home Planet")->getResourceType();
if(((Planet*)(obj->getObjectBehaviour()))->getResource(homeplanetid) == 1) {
//three more for home planets
shipcount += 3;
}
for(int i = 0; i < shipcount; i++) {
Combatant* f1 = new Combatant();
f1->setOwner(itmap->first);
f1->setObject(obj->getID());
f1->setShipType(0);
f1->setBattleXmlType("planet");
f1->setBattleXmlId(str(boost::format("planet-%1%-%2%") % obj->getID() % i));
f1->setBattleXmlName(str(boost::format("%1%'s colony on %2%, Defense battery %3%") % player->getName() % obj->getName() % i));
battlelogger->addCombatant(f1);
pcombatant.push_back(f1);
}
}
}
listallplayerids.insert(itmap->first);
battlelogger->endSide();
//sort combatant list by ship type, descending
sort(pcombatant.begin(), pcombatant.end(), CombatantSorter());
fleetcache[itmap->first] = pcombatant;
}
for(std::set<uint32_t>::iterator itplayer = listallplayerids.begin(); itplayer != listallplayerids.end(); ++itplayer) {
msgstrings[*itplayer] = "";
}
Random* random = Game::getGame()->getRandom();
Logger::getLogger()->debug("Combat start");
while(fleetcache.size() >= 2) {
battlelogger->startRound();
uint32_t pos1, pos2;
if(fleetcache.size() == 2) {
pos1 = 0;
pos2 = 1;
} else {
pos1 = pos2 = random->getInRange(0U, ((uint32_t)(fleetcache.size() - 1)));
while(pos2 == pos1) {
pos2 = random->getInRange(0U, ((uint32_t)(fleetcache.size() - 1)));
}
}
std::map<uint32_t, std::vector<Combatant*> >::iterator itpa = fleetcache.begin();
advance(itpa, pos1);
std::map<uint32_t, std::vector<Combatant*> >::iterator itpb = fleetcache.begin();
advance(itpb, pos2);
//.........这里部分代码省略.........