本文整理汇总了C++中Fleet::TurnsRemaining方法的典型用法代码示例。如果您正苦于以下问题:C++ Fleet::TurnsRemaining方法的具体用法?C++ Fleet::TurnsRemaining怎么用?C++ Fleet::TurnsRemaining使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fleet
的用法示例。
在下文中一共展示了Fleet::TurnsRemaining方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
bool Fleet::operator == (const Fleet& fleet) const{
return (_ownerID==fleet.OwnerID() &&
_source_planet_id==fleet.SourcePlanetID() &&
_destination_planet_id==fleet.DestinationPlanetID() &&
_num_ships==fleet.NumShips() &&
_turns_remaining==fleet.TurnsRemaining() );
}
示例2: advanceState
void Planet::advanceState(uint nr_turns, Fleets* arrivingFleets){
Fleet* tempFleet;
for(uint i=1;i<=nr_turns;i++){
uint ships[NUM_PLAYERS];
ships[PLAYER_NEUTRAL]=ships[PLAYER_1]=ships[PLAYER_2]=0;
if(_ownerID!=PLAYER_NEUTRAL){
ships_count+=_growth_rate;
}
ships[_ownerID]=ships_count;
for(uint j=0;j<arrivingFleets->size();j++){
tempFleet = arrivingFleets->at(j);
if(tempFleet->TurnsRemaining()==i){
ships[tempFleet->OwnerID()]+=tempFleet->NumShips();
}
}
//std::cerr << "arriving ships: " << ships[0] << " " << ships[1] << " " << ships[2] << std::endl;
uint greatest_id = _ownerID;
uint second_greatest_id=0;
for(uint j=0;j<NUM_PLAYERS;j++){
if(ships[j]>ships[greatest_id]) greatest_id=j;
}
for(uint j=0;j<NUM_PLAYERS;j++){
if(j!=greatest_id && ships[j]>ships[second_greatest_id]) second_greatest_id=j;
}
//std::cerr << "Player " << greatest_id << " has ships: " << ships[greatest_id] << " second: " << second_greatest_id << " " << ships[second_greatest_id] << std::endl;
if(ships[greatest_id]==ships[second_greatest_id]){
ships_count = 0;
} else {
//std::cerr << "setting owner: " << greatest_id << " new ship count: " << ships[greatest_id]-ships[second_greatest_id] << std::endl;
_ownerID = greatest_id;
ships_count = ships[greatest_id]-ships[second_greatest_id];
}
}
}