本文整理汇总了C++中Site::ai_get_site_object方法的典型用法代码示例。如果您正苦于以下问题:C++ Site::ai_get_site_object方法的具体用法?C++ Site::ai_get_site_object怎么用?C++ Site::ai_get_site_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::ai_get_site_object方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ai_get_site_object
//--------- Begin of function SiteArray::ai_get_site_object -------//
//
// Notify AI units to acquire scrolls or gold coins available on the
// map.
//
void SiteArray::ai_get_site_object()
{
Site* sitePtr;
for( int i=1 ; i<=size() ; i++ )
{
if( site_array.is_deleted(i) )
continue;
sitePtr = site_array[i];
if( sitePtr->site_type == SITE_SCROLL ||
sitePtr->site_type == SITE_GOLD_COIN )
{
sitePtr->ai_get_site_object();
}
}
}
示例2: next_day
//--------- Begin of function SiteArray::next_day ----------//
//
void SiteArray::next_day()
{
if( info.game_date%30 == 0 )
{
generate_raw_site(); // check if we need to generate existing raw sites are being used up and if we need to generate new ones
}
//-- if there is any scroll or gold coins available, ask AI to get them --//
if(scroll_count || gold_coin_count)
{
int aiGetSiteObject = (info.game_date%5 == 0);
Site* sitePtr;
Location *locPtr;
for(int i=size(); i; i--)
{
if(is_deleted(i))
continue;
sitePtr = site_array[i];
switch(sitePtr->site_type)
{
case SITE_SCROLL:
case SITE_GOLD_COIN:
locPtr = world.get_loc(sitePtr->map_x_loc, sitePtr->map_y_loc);
//---- if the unit is standing on a scroll site -----//
if(locPtr->has_unit(UNIT_LAND))
{
sitePtr->get_site_object( locPtr->unit_recno(UNIT_LAND) );
}
else if(aiGetSiteObject)
{
sitePtr->ai_get_site_object();
}
break;
}
}
}
//-------- debug testing --------//
#ifdef DEBUG
if( info.game_date%10 == 0 )
{
Site* sitePtr;
Location* locPtr;
for( int i=1 ; i<=size() ; i++ )
{
if( site_array.is_deleted(i) )
continue;
sitePtr = site_array[i];
locPtr = world.get_loc( sitePtr->map_x_loc, sitePtr->map_y_loc );
err_when( !locPtr->has_site() );
err_when( locPtr->site_recno() != i );
if( sitePtr->has_mine )
{
err_when( !locPtr->is_firm() );
err_when( firm_array[locPtr->firm_recno()]->firm_id != FIRM_MINE );
}
else
{
err_when( locPtr->is_firm() || locPtr->is_town() );
}
}
}
#endif
}
示例3: next_day
//--------- Begin of function SiteArray::next_day ----------//
//
void SiteArray::next_day()
{
if( info.game_date%30 == 0 )
{
generate_raw_site(); // check if we need to generate existing raw sites are being used up and if we need to generate new ones
}
//-- if there is any scroll or gold coins available, ask AI to get them --//
// #### begin Gilbert 3/11 ######//
if(scroll_count || gold_coin_count || item_count || weapon_blueprint_count )
// #### end Gilbert 3/11 ######//
{
int aiGetSiteObject = (info.game_date%5 == 0);
Site* sitePtr;
Location *locPtr;
for(int i=size(); i; i--)
{
if(is_deleted(i))
continue;
sitePtr = site_array[i];
switch(sitePtr->site_type)
{
case SITE_SCROLL:
case SITE_GOLD_COIN:
case SITE_ITEM:
case SITE_WEAPON_BLUEPRINT:
locPtr = world.get_loc(sitePtr->map_x_loc, sitePtr->map_y_loc);
//---- if the unit is standing on a scroll site -----//
if(locPtr->unit_recno(UNIT_LAND))
{
// ####### begin Gilbert 25/5 ##########//
int unitRecno = locPtr->unit_recno(UNIT_LAND);
if( !unit_array.is_deleted(unitRecno) )
sitePtr->get_site_object( unitRecno );
// ####### end Gilbert 25/5 ##########//
}
else if(aiGetSiteObject)
{
sitePtr->ai_get_site_object();
}
break;
}
}
}
//-------- debug testing --------//
#ifdef DEBUG
if( info.game_date%10 == 0 )
{
Site* sitePtr;
Location* locPtr;
for( int i=1 ; i<=size() ; i++ )
{
if( site_array.is_deleted(i) )
continue;
sitePtr = site_array[i];
locPtr = world.get_loc( sitePtr->map_x_loc, sitePtr->map_y_loc );
err_when( !locPtr->has_site() );
err_when( locPtr->site_recno() != i );
if( sitePtr->has_mine )
{
err_when( !locPtr->is_firm() );
err_when( firm_array[locPtr->firm_recno()]->firm_id != FIRM_MINE
&& firm_array[locPtr->firm_recno()]->firm_id != FIRM_ALCHEMY );
}
else
{
// disable because a mine can be upon more than one mine
// err_when( locPtr->is_firm() || locPtr->is_town() );
}
}
}
#endif
}