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


C++ PlayerState::get_id方法代码示例

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


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

示例1: pay

GameRules::EGR_result GameRules::pay(int& amt)
{
	PlayerState& plr = fState->get_player(fState->get_current_turn());
	PlayerState* onr = NULL; 
	unsigned pay = 0;

	// check to see if we are dealing with an ownable property
	if (fState->get_property(fMoveTo).has_owner())
		onr = &(fState->get_player(fState->get_property(fMoveTo).get_owner()));

	// figure out how much the player owes
	switch (fBase.type(fMoveTo))
	{
		case Game_Base::kITax:		// percentage tax
			pay = plr.get_money() * fBase.price(fMoveTo) / 100;
			break;
		case Game_Base::kLTax:		// flat tax
			pay = fBase.price(fMoveTo);
			break;
		case Game_Base::kUtil:		// utility
			pay = fRoll * count_mems(*onr, fMoveTo) * 4;
			break;
		case Game_Base::kRRoad:	// rail road
			pay = fBase.rent(fMoveTo, count_mems(*onr, fMoveTo) - 1);
			break;
		case Game_Base::kProp:		// property
			pay = fBase.rent(fMoveTo, fState->get_property(fMoveTo).get_level());
			if (fState->get_property(fMoveTo).get_level() == 0 &&
				owns_group((unsigned)onr->get_id(), fBase.group(fMoveTo)))
				pay *= 2;

			break;
	}

	// return the amount to be paid
	amt = pay;

	// check for insufficient assets
	if (plr.get_money() < pay)
		if (!free(plr.get_id(), pay))	// if still insufficient
		{
			if (Game_Base::kUtil <= fBase.type(fMoveTo))
				onr->add_money(plr.get_money());		// tranfer whatever they have
			return kConcede;						// and send concede signal
		}

	// if they have enough, transfer funds to owner
	plr.sub_money(pay);
	if (Game_Base::kUtil <= fBase.type(fMoveTo)) onr->add_money(pay);

	return kDone;
}
开发者ID:kylegibson,项目名称:yloponom,代码行数:52,代码来源:GameRules.C


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