本文整理汇总了C++中Pokemon::getNickname方法的典型用法代码示例。如果您正苦于以下问题:C++ Pokemon::getNickname方法的具体用法?C++ Pokemon::getNickname怎么用?C++ Pokemon::getNickname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pokemon
的用法示例。
在下文中一共展示了Pokemon::getNickname方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doBattle
void Battle::doBattle(Pokemon& attacking, Pokemon& defending, Move& move)
{
// print the pokemon and move involved in this battle
println_debug("Running Battle");
cout << attacking.getNickname() << " used " << move.getName() << "."
<< endl;
// determine if move will hit
bool moveHit = willMoveHit(attacking, defending, move);
if(moveHit)
{
// do the actual move
if(move.getCategory() == STATUS)
{
// status moves just use a hook
move.doEffect(attacking, defending);
}
else
{
// physical and special moves do damage
int damage = getDamage(attacking, defending, move);
defending.changeHp(-damage);
}
// hook for post-move effect
move.onMoveEnd(attacking, defending, moveHit);
}
else
{
// print miss statement
cout << attacking.getNickname() << "'s attack missed." << endl;
}
}
示例2: 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);
}
示例3:
void IncreaseSpeed2::doEffect(const Move& move, Pokemon& owner, Pokemon& defending)
{
Stat& speed = owner.getSpeed();
println_debug("Current speed: " << speed.getModValue());
speed -= 2;
cout << owner.getNickname() << "'s speed rose." << endl;
println_debug("Current speed: " << speed.getModValue());
}
示例4: calcHitProb
float Battle::calcHitProb(Pokemon& attacking, Pokemon& defending, Move& move)
{
// calculate using move accuracy, pokemon accuracy, and pokemon evasiveness
float moveAcc = move.getAccuracy();
float pokemonAcc = attacking.getAccuracy().getModValue();
float pokemonEva = defending.getEvasiveness().getModValue();
float hitProb = moveAcc * pokemonAcc / pokemonEva;
// debug messages
println_debug("Probability of " << attacking.getNickname() << " hitting "
<< defending.getNickname() << " with " << move.getName());
println_debug("Move Accuracy: " << moveAcc);
println_debug("Attacking Pokemon Accuracy: " << pokemonAcc);
println_debug("Defending Pokemon Evasiveness: " << pokemonEva);
println_debug("Chance of hit: " << hitProb);
return hitProb;
}