当前位置: 首页>>代码示例>>C++>>正文


C++ Fleet::TurnsRemaining方法代码示例

本文整理汇总了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() );
}
开发者ID:9thbit,项目名称:Planet-Wars,代码行数:7,代码来源:Fleet.cpp

示例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];
		}
	}
}
开发者ID:9thbit,项目名称:Planet-Wars,代码行数:39,代码来源:Planet.cpp


注:本文中的Fleet::TurnsRemaining方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。