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


C++ Town::average_loyalty方法代码示例

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


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

示例1: put_town_rec

//-------- Begin of static function put_town_rec --------//
//
static void put_town_rec(int recNo, int x, int y, int refreshFlag)
{
	int   townRecno = town_filter(recNo);
	Town* townPtr   = town_array[townRecno];

	//---------- display info ----------//

	x+=3;
	y+=3;

	font_san.put( x    , y, townPtr->town_name() );
	font_san.put( x+175, y, townPtr->population );
	font_san.put( x+241, y, townPtr->jobless_population );
	font_san.put( x+309, y, townPtr->average_loyalty() );

	//------- display race icons -------//

	x += 350;

	int i;
	int iconSpacing = RACE_ICON_WIDTH+2;
#if(MAX_RACE > 7)
	int raceCount = 0;
	for( i=0 ; i<MAX_RACE ; i++ )
	{
		if( townPtr->race_pop_array[i] > 0 )
		{
			++raceCount;
		}
	}
	if( raceCount > 7 )
	{
		iconSpacing = 7 * iconSpacing / raceCount;
	}
#endif
	for( i=0 ; i<MAX_RACE ; i++ )
	{
		if( townPtr->race_pop_array[i] > 0 )
		{
			vga_back.put_bitmap( x, y-2, race_res[i+1]->icon_bitmap_ptr );
			x += iconSpacing;
		}
	}
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:46,代码来源:OR_TOWN.cpp

示例2: capture_expected_resistance

//--------- Begin of function Nation::capture_expected_resistance --------//
//
// The lowest resistance can be expected if we are going to capture the
// town.
//
int Nation::capture_expected_resistance(int townRecno)
{
	//--- we have plenty of cash, use cash to decrease the resistance of the villagers ---//

	if( should_use_cash_to_capture() )
		return 0;			// return zero resistance

	//----- the average resistance determines the captureRating ------//

	int	captureRating = 0;
	Town* townPtr = town_array[townRecno];

	int averageResistance;

	if( townPtr->nation_recno )
		averageResistance = townPtr->average_loyalty();
	else
		averageResistance = townPtr->average_resistance(nation_recno);

	//----- get the id. of the most populated races in the town -----//

	int majorityRace = townPtr->majority_race();

	err_when( !majorityRace );		// this should not happen

	//---- see if there are general available for capturing this town ---//

	int targetResistance=0;

	if( !find_best_capturer(townRecno, majorityRace, targetResistance) )
		return 100;

	int resultResistance =
		( targetResistance * townPtr->race_pop_array[majorityRace-1] +
		  averageResistance * (townPtr->population - townPtr->race_pop_array[majorityRace-1]) )
		/ townPtr->population;

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


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