本文整理汇总了C++中Monster::attacksFor方法的典型用法代码示例。如果您正苦于以下问题:C++ Monster::attacksFor方法的具体用法?C++ Monster::attacksFor怎么用?C++ Monster::attacksFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monster
的用法示例。
在下文中一共展示了Monster::attacksFor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fight
void fight(Player p, Monster mob)
{
cout << "A WILD " << sandetra::capslock(mob.getName()) << " APPEAERS!" << endl;
while (mob.getHitpoints() > 0 && p.getHitpoints() > 0) {
mob.takeDamage(p.attacksFor());
if (mob.getHitpoints() <= 0) {
cout << mob.getName() << " has been defeated!" << endl;
cout << p.getName() << " uses a potion to return to full health." << endl;
p.setHitpoints(30);
return;
} else {
if (rand() % 3 == 2) {
cout << "You have a chance to parry the attack!" << endl;
if (twoscomp_quiz()) {
cout << "ATTACK SUCCESSFULLY PARRIED!" << endl;
} else p.takeDamage(mob.attacksFor());
} else {
p.takeDamage(mob.attacksFor());
}
if (p.getHitpoints() <= 0) {
cout << p.getName() << " has fallen! OH NO!!!!" << endl; //Game over not implemented.
cout << p.getName() << " uses a potion!" << endl;
p.setHitpoints(15);
return;
}
}
}
}