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


C++ Nation::add_food方法代码示例

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


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

示例1: if

void CampaignEastWest::plot_a2_next_day()
{

	// give food, money and live point if lack

	if( !nation_array.is_deleted(plot_enemy_nation_recno))
	{
		Nation *monsterNation = nation_array[plot_enemy_nation_recno];

		if( monsterNation->cash < 1000.0f )
			monsterNation->add_income(INCOME_CHEAT, 10.0f, 1);
		else if( monsterNation->cash < 5000.0f )
			monsterNation->add_income(INCOME_CHEAT, 2.0f, 1);

		if( monsterNation->food < 1000.0f )
			monsterNation->add_food( 10.0f );
		else if( monsterNation->food < 5000.0f )
			monsterNation->add_food( 2.0f );

		if( monsterNation->live_points < 1000.0f )
			monsterNation->change_live_points( 10.0f );
		else if( monsterNation->live_points < 5000.0f )
			monsterNation->change_live_points( 2.0f );
	}
}
开发者ID:112212,项目名称:7k2,代码行数:25,代码来源:oc_pla2.cpp

示例2: process_accepted_reply


//.........这里部分代码省略.........
				}

				else if( toNation->get_relation_status(talk_para1) == RELATION_FRIENDLY )
				{
					memset(&talkMsg, 0, sizeof(TalkMsg));

					talkMsg.to_nation_recno   = (char) talk_para1;
					talkMsg.from_nation_recno = to_nation_recno;
					talkMsg.talk_id  			  = TALK_END_FRIENDLY_TREATY;

					talk_res.send_talk_msg( &talkMsg, COMMAND_AUTO );
				}

				//--- send a declare war message to the target kingdom ---//

				memset(&talkMsg, 0, sizeof(TalkMsg));

				talkMsg.to_nation_recno   = (char) talk_para1;
				talkMsg.from_nation_recno = to_nation_recno;
				talkMsg.talk_id  			  = TALK_DECLARE_WAR;

				talk_res.send_talk_msg( &talkMsg, COMMAND_AUTO );

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

				goodRelationDec = 10;
			}
			break;

		case TALK_REQUEST_BUY_FOOD:
		{
			int buyCost = talk_para1 * talk_para2 / 10;

			fromNation->add_food( (float) talk_para1 );
			fromNation->add_expense( EXPENSE_IMPORTS, (float) buyCost, 0 );
			toNation->consume_food( (float) talk_para1 );
			toNation->add_income( INCOME_EXPORTS, (float) buyCost, 0 );
			break;
		}

		case TALK_DECLARE_WAR:
			toRelation->started_war_on_us_count++;			// how many times this nation has started a war with us, the more the times the worse this nation is.
			toNation->set_relation_status(from_nation_recno, RELATION_HOSTILE);

			fromRelation->set_never_accept_until_date(TALK_REQUEST_CEASE_WAR, 150);
			toRelation->set_never_accept_until_date(TALK_REQUEST_CEASE_WAR, 150);

			fromRelation->set_never_accept_until_date(TALK_GIVE_TRIBUTE, 300);
			toRelation->set_never_accept_until_date(TALK_GIVE_TRIBUTE, 300);

			//--- decrease reputation of the nation which declares war ---//

			if( toNation->reputation > 0 )
				fromNation->change_reputation( -toNation->reputation * 20 / 100 );
			break;

		case TALK_GIVE_TRIBUTE:
		case TALK_GIVE_AID:
			fromNation->give_tribute( to_nation_recno, talk_para1 );
			break;

		case TALK_DEMAND_TRIBUTE:
		case TALK_DEMAND_AID:
			toNation->give_tribute( from_nation_recno, talk_para1 );
			goodRelationDec = talk_para1/200;
			break;
开发者ID:112212,项目名称:7k2,代码行数:67,代码来源:otalkmsg.cpp


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