Exemplo n.º 1
0
bool client_lib_t::add_income( const income_t& income ) const
{
    ok_t ok_res;
    add_income_t add_income( income.cat, income.value );

    if ( !execute_command( add_income, ok_res ) )
    {
        return false;
    }

    return true;
}
Exemplo n.º 2
0
//------- Begin of function FirmMarket::sell_goods -----------//
//
// Sell products to consumers. Called by Town::sell_goods()
//
void FirmMarket::sell_goods()
{
	//----------- sell products now ------------//

	int   	 		i;
	float			   saleQty;
	MarketGoods*	marketGoods;
	float				consumerPrice = CONSUMER_PRICE;

	//-------- increased cash for human players -------//

	if( !is_ai )   	// Human players
	{
		switch( config.start_up_cash )
		{
			case OPTION_VERY_HIGH:
				consumerPrice += 2.5;
				break;

			case OPTION_HIGH:
				consumerPrice += 1.5;
				break;
		}
	}
	else					// AI
	{
		switch( config.ai_start_up_cash )
		{
			case OPTION_VERY_HIGH:
				consumerPrice += 2;
				break;

			case OPTION_HIGH:
				consumerPrice += 1;
				break;
		}
	}

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

	for( i=0, marketGoods=market_goods_array ; i<MAX_MARKET_GOODS ; i++, marketGoods++ )
	{
		if( marketGoods->product_raw_id && marketGoods->stock_qty > 0 )
		{
			saleQty = min(marketGoods->month_demand/30, marketGoods->stock_qty);

			marketGoods->stock_qty -= saleQty;

			marketGoods->cur_month_sale_qty += saleQty;

			float sales = saleQty * consumerPrice;
			// ##### begin Gilbert 16/2 #######//
			if( nation_recno && god_res[GOD_CHINESE]->nation_prayer_count(nation_recno) > 0 )
				// sales = sales * 1.20f;		// profit incrase by 20%
				sales = sales * 1.30f;		// profit incrase by 30%
			// ##### end Gilbert 16/2 #######//
			marketGoods->cur_year_sales  	  += sales;

			// AI_CHEAT

			if( is_ai && config.ai_aggressiveness > OPTION_MODERATE )
				sales += sales * (config.ai_aggressiveness-OPTION_MODERATE) / 4;		// 25% more cash if AI aggressivness is high, 50% more if aggressiveness is very high

			add_income(INCOME_SELL_GOODS, sales);
		}
	}
}