本文整理汇总了C++中Pokemon::getTypeTwo方法的典型用法代码示例。如果您正苦于以下问题:C++ Pokemon::getTypeTwo方法的具体用法?C++ Pokemon::getTypeTwo怎么用?C++ Pokemon::getTypeTwo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pokemon
的用法示例。
在下文中一共展示了Pokemon::getTypeTwo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDamage
int Battle::getDamage(Pokemon& attacking, Pokemon& defending, Move& move)
{
// get the pokemon's level
int level = attacking.getLevel();
// get the relavent values for attack and defense
int attackStat;
int defenseStat;
if(move.getCategory() == PHYSICAL)
{
attackStat = attacking.getAttack().getModValue();
defenseStat = defending.getDefense().getModValue();
}
else
{
attackStat = attacking.getSpecialAttack().getModValue();
defenseStat = defending.getSpecialDefense().getModValue();
}
// get the moves power
double attackPower = move.getPower();
// get the stab
double STAB = 1.0;
if(attacking.getTypeOne() == move.getType() or attacking.getTypeTwo() ==
move.getType())
{
STAB = 1.5;
}
// get the type multiplier
double typeMult = Type::getMultiplier(move.getType(), defending.getTypeOne(),
defending.getTypeTwo());
// get the random number 85-100
double randomNumber = (rand() % 16) + 85;
// do the calculation
double damage = ((((2.0 * level / 5.0 + 2.0) * attackStat * attackPower /
defenseStat) / 50.0) + 2.0) * STAB * typeMult *
randomNumber / 100.0;
// print debug messages
println_debug("Damage for " << attacking.getNickname() << " attacking " <<
defending.getNickname() << " with " << move.getName());
println_debug("Level = " << level);
println_debug("attackStat = " << attackStat);
println_debug("attackPower = " << attackPower);
println_debug("defenseStat = " << defenseStat);
println_debug("STAB = " << STAB);
println_debug("type = " << typeMult);
println_debug("random = " << randomNumber);
println_debug("Damage calculated = " << damage);
println_debug("");
// round damage
return roundDamage(damage);
}