Beispiel #1
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();
}
Beispiel #2
0
//------- Begin of function FirmMarket::think_market_build_factory ------//
//
void FirmMarket::think_market_build_factory()
{
	if( no_neighbor_space )		// if there is no space in the neighbor area for building a new firm.
		return;

	//---- think about building factories to manufacture goods using raw materials in the market place ---//

	MarketGoods* marketGoods = market_goods_array;
	Firm* firmPtr;

	ai_should_build_factory_count = 2;		// always set it to 2, so think_build_factory() will start to build a market as soon as there is a need

	for( int i=0 ; i<MAX_MARKET_GOODS ; i++, marketGoods++ )
	{
		if( !marketGoods->raw_id )
			continue;

		if( marketGoods->stock_qty < 250 )		// only when the stock is >= 250
			continue;

		//----- check if the raw materials are from a local mine, if so don't build a factory, we only build a factory to manufacture goods using raw materials from a remote town.

		int j;
		for( j=0 ; j<linked_firm_count ; j++ )
		{
			firmPtr = firm_array[ linked_firm_array[j] ];

			if( firmPtr->firm_id == FIRM_MINE &&
				 firmPtr->nation_recno == nation_recno &&
				 ((FirmMine*)firmPtr)->raw_id == marketGoods->raw_id )
			{
				break;
			}
		}

		if( j<linked_firm_count )		// if this raw material is from a local mine
			continue;

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

		if( think_build_factory(marketGoods->raw_id) )
			return;
	}
}
Beispiel #3
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();
}