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


C++ Arena::Roll方法代码示例

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


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

示例1: defense

/*********************************************************************************
*Description - Defense fn 
*fn that send number of die and faces to Arena class and assesses the amount of 
*damage received 
*Parameters - Passes the amount of damage received to the the Armor fn, using 
polymorphism
*********************************************************************************/
void Reptile::defense() {

	int defend, damage, impact;

	battle3.setNumFaces(R_DEFEND_FACE);
	battle3.setNumDice(R_DEFEND_DIE);
	defend = battle3.Roll();	

	battle3.setDefendRoll(defend);
	damage = battle3.deathBlow();

		if(damage == 0)
		{
			cout << "No damage!!" << endl;
		}
			
			else if(damage > R_ARMOR)
			{	
				impact = damage - R_ARMOR;
				cout << "The Reptile People were injured! Because of armor, it only had an impact of: -"<< impact << endl; 
			}
			
				else if((damage > 0) && (damage <= R_ARMOR))
				{
					cout << "The Reptile People were hit, but were saved by their armor!!" << endl;
				}
	
				Character *chr = &rep;
				chr->armor(damage);
				chr->strength();

}
开发者ID:jtoth955,项目名称:CS-162,代码行数:39,代码来源:Reptile.cpp

示例2: attack

/*********************************************************************************
*Description - Attack fn Fn that passes number of die and die faces to Arena fn 
*Parameters - CONST for number of die and die faces
*********************************************************************************/
void Reptile::attack() {
	
	int attack;

	battle3.setNumFaces(R_ATTACK_FACE);
	battle3.setNumDice(R_ATTACK_DIE);
	attack = battle3.Roll();

	cout << "The Reptile People delivered a heavy blow to the opponent with a force of: " << attack << endl;
	
	battle3.setAttackRoll(attack);

}
开发者ID:jtoth955,项目名称:CS-162,代码行数:17,代码来源:Reptile.cpp


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