Esempio n. 1
0
//------- Begin of function FirmMarket::think_del -----------//
//
// Think about deleting this firm.
//
int FirmMarket::think_del()
{
	if( linked_town_count > 0 )
	{
		no_linked_town_since_date = 0;		// reset it
		return 0;
	}
	else
	{
		no_linked_town_since_date = info.game_date;
	}

	//---- don't delete it if there are still signiciant stockhere ---//

	if( stock_value_index() >= 10 )
	{
		Nation* ownNation = nation_array[nation_recno];

		//--- if the market has been sitting idle for too long, delete it ---//

		if( info.game_date < no_linked_town_since_date
			 + 180 + 180 * ownNation->pref_trading_tendency / 100 )
		{
			return 0;
		}
	}

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

	ai_del_firm();

	return 1;
}
Esempio n. 2
0
//------- Begin of function FirmMine::process_ai -----------//
//
void FirmMine::process_ai()
{
	//---- if the reserve has exhaust ----//

	if( !raw_id || reserve_qty==0 )
	{
		err_when( under_construction );

		ai_del_firm();
		return;
	}

	//---- think about building factory and market place to link to ----//

	if( productivity > 0 )		// only do so if productivity > 0
	{
		int rc = info.game_date%30==firm_recno%30;

		if( nation_array[nation_recno]->ai_factory_count==0 )		// if the nation doesn't have any factories yet, give building factory a higher priority
			rc = info.game_date%5==firm_recno%5;

		if( rc )
		{
			if( !think_build_factory(raw_id) )
				ai_should_build_factory_count = 0;		// reset the counter

			think_build_market();		// don't build it in FirmMine, when it builds a factory the factory will build a mine.
		}
	}

	//---- call parent class process_ai() ------//

	FirmWork::process_ai();
}
Esempio n. 3
0
//------- Begin of function FirmWar::think_del -----------//
//
// Think about deleting this firm.
//
int FirmWar::think_del()
{
	if( worker_count > 0 )
		return 0;

	//-- check whether the firm is linked to any towns or not --//

	for( int i=0 ; i<linked_town_count ; i++ )
	{
		if( linked_town_enable_array[i] == LINK_EE )
			return 0;
	}

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

	ai_del_firm();

	return 1;
}
Esempio n. 4
0
//------- Begin of function FirmMine::process_ai -----------//
//
void FirmMine::process_ai()
{
	//---- if the reserve has exhaust ----//

	if( !raw_id || reserve_qty==0 )
	{
		err_when( under_construction );

		ai_del_firm();
		return;
	}

	//------- recruit workers ---------//

	if( info.game_date%15==firm_recno%15 )
	{
		if( worker_count < MAX_WORKER )
			ai_recruit_worker();
	}

	//---- think about building factory and market place to link to ----//

	int rc = info.game_date%30==firm_recno%30;

	if( nation_array[nation_recno]->ai_factory_count==0 )		// if the nation doesn't have any factories yet, give building factory a higher priority
		rc = info.game_date%5==firm_recno%5;

	if( rc )
	{
		if( !think_build_factory(raw_id) )
			ai_should_build_factory_count = 0;		// reset the counter

  		think_build_market();		// don't build it in FirmMine, when it builds a factory the factory will build a mine.
	}

	//---- think about ways to increase productivity ----//

	if( info.game_date%30==firm_recno%30 )
		think_inc_productivity();
}