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


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

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


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

示例1: ai_assign_spy_to_firm

//--------- Begin of function Nation::ai_assign_spy_to_firm --------//
//
// Think about sending spies to the specific firm.
//
// return: <int> 1 - a spy is assigned successfully.
// 				  0 - failure.
//
int Nation::ai_assign_spy_to_firm(int firmRecno)
{
	Firm* firmPtr = firm_array[firmRecno];

	err_when( !firmPtr->worker_array );

	//---- check if the firm is full or not -----//

	if( firmPtr->nation_recno == nation_recno )	// if it's our own firm
	{
		if( firmPtr->is_worker_full() )	// use is_worker_full() for own firms as it take into account of units patrolling outside
			return 0;
	}
	else
	{
		if( firmPtr->worker_count == MAX_WORKER )
			return 0;
	}

	//------ look for an existing spy -------//

	int raceId	   = firmPtr->majority_race();
	int mobileOnly = firmPtr->nation_recno == nation_recno;   // if assign to own firms/firms, only get mobile spies, don't get spies from existing firms/firms as that will result in a loop effect

	return ai_assign_spy( firmPtr->loc_x1, firmPtr->loc_y1, raceId, mobileOnly );
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:33,代码来源:OAI_SPY.cpp

示例2: mobilize_capturer

//-------- Begin of function Nation::mobilize_capturer ------//
//
// Mobilize the capturer unit if he isn't mobilized yet.
//
int Nation::mobilize_capturer(int unitRecno)
{
	//--- if the picked unit is an overseer of an existng camp ---//

	Unit* unitPtr = unit_array[unitRecno];

	if( unitPtr->unit_mode == UNIT_MODE_OVERSEE )
	{
		Firm* firmPtr = firm_array[unitPtr->unit_mode_para];
		Town* townPtr;

		//-- can recruit from either a command base or seat of power --//

		//-- train a villager with leadership to replace current overseer --//

		int i;
		for( i=0 ; i<firmPtr->linked_town_count ; i++ )
		{
			townPtr = town_array[ firmPtr->linked_town_array[i] ];

			if( townPtr->nation_recno != nation_recno )
				continue;

			//--- first try to train a unit who is racially homogenous to the commander ---//

			int unitRecno = townPtr->recruit( SKILL_LEADING, firmPtr->majority_race(), COMMAND_AI );

			//--- if unsucessful, then try to train a unit whose race is the same as the majority of the town ---//

			if( !unitRecno )
				unitRecno = townPtr->recruit( SKILL_LEADING, townPtr->majority_race(), COMMAND_AI );

			if( unitRecno )
			{
				add_action(townPtr->loc_x1, townPtr->loc_y1, -1, -1, ACTION_AI_ASSIGN_OVERSEER, FIRM_CAMP);
				break;
			}
		}

		if( i==firmPtr->linked_town_count )			// unsuccessful
			return 0;

		//------- mobilize the current overseer --------//

		firmPtr->mobilize_overseer();
	}

	return 1;
}
开发者ID:MicroVirus,项目名称:7kaa,代码行数:53,代码来源:OAI_CAPT.cpp

示例3: think_assign_spy_target_camp

//-------- Begin of function Nation::think_assign_spy_target_camp --------//
//
// Think about planting spies into independent towns and enemy towns.
//
int Nation::think_assign_spy_target_camp(int raceId, int regionId)
{
	Firm  *firmPtr;
	int	curRating, bestRating=0, bestFirmRecno=0;

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

		firmPtr = firm_array[firmRecno];

		if( firmPtr->nation_recno == nation_recno )		// don't assign to own firm
			continue;

		if( firmPtr->region_id != regionId )
			continue;

		if( firmPtr->overseer_recno == 0 ||
			 firmPtr->worker_count == MAX_WORKER )
		{
			continue;
		}

		if( firmPtr->majority_race() != raceId )
			continue;

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

		Unit* overseerUnit = unit_array[firmPtr->overseer_recno];

		if( overseerUnit->spy_recno )		// if the overseer is already a spy
			continue;

		curRating = 100 - overseerUnit->loyalty;

		if( curRating > bestRating )
		{
			bestRating 	  = curRating;
			bestFirmRecno = firmRecno;
		}
	}

	return bestFirmRecno;
}
开发者ID:spippolatore,项目名称:7kaa,代码行数:49,代码来源:OAI_SPY.cpp


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