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


C++ Firm::cast_to_FirmTrain方法代码示例

本文整理汇总了C++中Firm::cast_to_FirmTrain方法的典型用法代码示例。如果您正苦于以下问题:C++ Firm::cast_to_FirmTrain方法的具体用法?C++ Firm::cast_to_FirmTrain怎么用?C++ Firm::cast_to_FirmTrain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Firm的用法示例。


在下文中一共展示了Firm::cast_to_FirmTrain方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: update_firm_spy_count

//--------- Begin of function SpyArray::update_firm_spy_count ---------//
//
// Update the player_spy_count of this firm. This function is called
// when the firm change its nation.
//
// <int> firmRecno - recno of the firm to be updated.
//
void SpyArray::update_firm_spy_count(int firmRecno)
{
	//---- recalculate Firm::player_spy_count -----//

	Spy*  spyPtr;
	Firm* firmPtr = firm_array[firmRecno];

	if( firmPtr->cast_to_FirmCamp() )
	{
		FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp();
		firmCamp->player_spy_count = 0;
		for( int i=spy_array.size() ; i>0 ; i-- )
		{
			if( spy_array.is_deleted(i) )
				continue;

			spyPtr = spy_array[i];

			if( spyPtr->spy_place == SPY_FIRM &&
				 spyPtr->spy_place_para == firmRecno &&
				 spyPtr->true_nation_recno == nation_array.player_recno )
			{
				firmCamp->player_spy_count++;
			}
		}
	}
	else if( firmPtr->cast_to_FirmTrain() )
	{
		FirmTrain *firmTrain = firmPtr->cast_to_FirmTrain();
		firmTrain->player_spy_count = 0;
		for( int i=spy_array.size() ; i>0 ; i-- )
		{
			if( spy_array.is_deleted(i) )
				continue;

			spyPtr = spy_array[i];

			if( spyPtr->spy_place == SPY_FIRM &&
				 spyPtr->spy_place_para == firmRecno &&
				 spyPtr->true_nation_recno == nation_array.player_recno )
			{
				firmTrain->player_spy_count++;
			}
		}
	}

	return;
}
开发者ID:mecirt,项目名称:7k2,代码行数:55,代码来源:ospya.cpp

示例2: update_total_human_count

//------- Begin of function NationArray::update_total_human_count ------//
//
// Update total human count as there are some bugs in calculation of
// total human count. This function is used for on-fly correcting
// the problem.
//
void NationArray::update_total_human_count()
{
	int totalHumanCountArray[MAX_NATION];

	memset( totalHumanCountArray, 0, sizeof(totalHumanCountArray) );

	//------ calculate firm statistic -------//

	Firm* firmPtr;

	int i;
	for( i=firm_array.size() ; i>0 ; i-- )
	{
		if( firm_array.is_deleted(i) )
			continue;

		firmPtr = firm_array[i];

		if( firmPtr->nation_recno == 0 || !firmPtr->is_human() )
			continue;

		if( firmPtr->cast_to_FirmCamp() )
		{
			FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp();

			for( int j=firmCamp->soldier_count-1 ; j>=0 ; j-- )
			{
				if( firmCamp->soldier_array[j].is_human() )
					totalHumanCountArray[firmCamp->nation_recno-1]++;
			}
		}

		if( firmPtr->cast_to_FirmTrain() )
		{
			FirmTrain *firmTrain = firmPtr->cast_to_FirmTrain();

			totalHumanCountArray[firmTrain->nation_recno-1] += firmTrain->trainee_count;
		}
	}

	//------ calculate unit statistic -------//

	Unit* unitPtr;

	for( i=unit_array.size() ; i>0 ; i-- )
	{
		if( unit_array.is_truly_deleted(i) )
			continue;

		unitPtr = unit_array[i];

		if( unitPtr->nation_recno && unitPtr->is_human() &&
			 unitPtr->rank_id != RANK_KING )		// does not count kings
		{
			if( unitPtr->unit_id == UNIT_WAGON )
				totalHumanCountArray[unitPtr->nation_recno-1] += unitPtr->cast_to_UnitWagon()->population;
			else
				totalHumanCountArray[unitPtr->nation_recno-1]++;
		}
	}

	//------ update nation statistic ------//

	for( i=size() ; i>0 ; i-- )
	{
		if( nation_array.is_deleted(i) )
			continue;

		nation_array[i]->total_human_count = totalHumanCountArray[i-1];
	}
}
开发者ID:112212,项目名称:7k2,代码行数:77,代码来源:onationa.cpp

示例3: update_military_rating

//------- Begin of function NationArray::update_military_rating ------//
//
void NationArray::update_military_rating()
{
	int nationCombatLevelArray[MAX_NATION];

	memset( nationCombatLevelArray, 0, sizeof(nationCombatLevelArray) );

	//------ calculate firm statistic -------//

	Firm* firmPtr;

	int i;
	for( i=firm_array.size() ; i>0 ; i-- )
	{
		if( firm_array.is_deleted(i) )
			continue;

		firmPtr = firm_array[i];

		if( firmPtr->nation_recno == 0 )
			continue;

		if( firmPtr->cast_to_FirmCamp() )
		{
			FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp();

			nationCombatLevelArray[firmPtr->nation_recno-1] +=
				firmCamp->total_combat_level() +
				(firmCamp->overseer_recno>0 + firmCamp->soldier_count) * 20;
				// 20 is the base military points for a unit, so the nation that has many more units can be reflected in the military rating
		}
		// ###### patch begin 9/11 ########//
		else if( firmPtr->cast_to_FirmTrain() )
		{
			FirmTrain *firmTrain = firmPtr->cast_to_FirmTrain();

			nationCombatLevelArray[firmPtr->nation_recno-1] +=
				firmTrain->total_military_combat_level() +
				firmTrain->total_military_count() * 20;
				// 20 is the base military points for a unit, so the nation that has many more units can be reflected in the military rating
		}
		// ###### patch end 9/11 ########//
	}

	//------ calculate unit statistic -------//

	Unit* unitPtr;

	for( i=unit_array.size() ; i>0 ; i-- )
	{
		if( unit_array.is_deleted(i) )
			continue;

		unitPtr = unit_array[i];

		if( unitPtr->nation_recno == 0 )
			continue;

		//---- if this unit is a ship, increase total_ship_combat_level ----//

		if( unit_res[unitPtr->unit_id]->unit_class == UNIT_CLASS_SHIP )
		{
			nation_array[unitPtr->nation_recno]->total_ship_combat_level += (int) unitPtr->hit_points;
		}

		//----------------------------------//

		if( unitPtr->unit_mode == UNIT_MODE_OVERSEE )		// firm commanders are counted above with firm_array
			continue;

		int addPoints = (int) unitPtr->hit_points;

		UnitInfo* unitInfo = unit_res[unitPtr->unit_id];

		// ##### begin Gilbert 24/3 ########//
//		if( unitInfo->unit_class == UNIT_CLASS_WEAPON )
//			addPoints += (unitInfo->weapon_power + unitPtr->get_weapon_version() - 1) * 30;
		if( !unitInfo->class_info.has_combat_level )
		{
			addPoints += unitInfo->weapon_power * 30;
			if( unitInfo->class_info.has_weapon_version )
				addPoints += (unitPtr->get_weapon_version() - 1) * 30;
		}
		// ##### end Gilbert 24/3 ########//

		if( unitPtr->leader_unit_recno && !unit_array.is_deleted(unitPtr->leader_unit_recno) )
			addPoints += addPoints * unit_array[unitPtr->leader_unit_recno]->skill_level() / 100;

		nationCombatLevelArray[unitPtr->nation_recno-1] += addPoints + 20;		// 20 is the base military points for a unit, so the nation that has many more units can be reflected in the military rating
	}

	//------ update nation statistic ------//

	for( i=size() ; i>0 ; i-- )
	{
		if( nation_array.is_deleted(i) )
			continue;

		nation_array[i]->military_rating = nationCombatLevelArray[i-1]/50;
//.........这里部分代码省略.........
开发者ID:112212,项目名称:7k2,代码行数:101,代码来源:onationa.cpp

示例4: catch_spy

//-------- Begin of function SpyArray::catch_spy ------//
//
// <int> spyPlace - either SPY_TOWN or SPY_FIRM
// <int> spyPlacePara - town_recno or firm_recno
//
int SpyArray::catch_spy(int spyPlace, int spyPlacePara)
{
	int nationRecno, totalPop;

	if( spyPlace == SPY_TOWN )
	{
		Town* townPtr = town_array[spyPlacePara];

		nationRecno = townPtr->nation_recno;
		totalPop    = townPtr->population;
	}
	else if( spyPlace == SPY_FIRM )
	{
		Firm* firmPtr = firm_array[spyPlacePara];

		nationRecno = firmPtr->nation_recno;
		if( firmPtr->cast_to_FirmCamp() )
		{
			FirmCamp *firmCamp = firmPtr->cast_to_FirmCamp();
			totalPop    = firmCamp->soldier_count + (firmCamp->overseer_recno>0);
		}
		else if( firmPtr->cast_to_FirmWork() )
		{
			FirmWork *firmWork = firmPtr->cast_to_FirmWork();
			totalPop    = firmWork->worker_count;
		}
		else if( firmPtr->cast_to_FirmTrain() )
		{
			totalPop = firmPtr->cast_to_FirmTrain()->trainee_count;
			return 0;		// don't catch spy
		}
		else if( firmPtr->cast_to_FirmInn() )
		{
			totalPop = firmPtr->cast_to_FirmInn()->inn_unit_count;
			return 0;		// don't catch spy
		}
		else if( firmPtr->cast_to_FirmMarket() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmMonsterTrain() )
		{
			totalPop = firmPtr->cast_to_FirmMonsterTrain()->trainee_count;
			return 0;		// don't catch spy
		}
		else if( firmPtr->cast_to_FirmMonsterAlchemy() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmLishorr() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmMonsterFortress() )
		{
			FirmMonsterFortress *firmMonsterFortress = firmPtr->cast_to_FirmMonsterFortress();
			totalPop = firmMonsterFortress->archer_count + firmMonsterFortress->extra_builder_count;
		}
		else if( firmPtr->cast_to_FirmAnimal() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmIncubator() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmMagic() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmOffensive() )
		{
			totalPop = 0;
			return 0;
		}
		else if( firmPtr->cast_to_FirmOffensive2() )
		{
			totalPop = 0;
			return 0;
		}
		else
		{
			err_here();
			totalPop = 0;
		}
	}
	else
		err_here();

//.........这里部分代码省略.........
开发者ID:mecirt,项目名称:7k2,代码行数:101,代码来源:ospya.cpp


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