本文整理汇总了C++中Pokemon::get_name方法的典型用法代码示例。如果您正苦于以下问题:C++ Pokemon::get_name方法的具体用法?C++ Pokemon::get_name怎么用?C++ Pokemon::get_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pokemon
的用法示例。
在下文中一共展示了Pokemon::get_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attack
bool Colosseum::attack(const Pokemon& attacker, Pokemon& defender) //function that deals with attacks and lowers hit points if hit
{
bool returnValue=false;
cout << attacker.get_name() << " is attacking " << defender.get_name() << endl;
int attbonus=d20.roll();
int defbonus=d20.roll();
cout << attacker.get_name() << " rolls an attack bonus of " << attbonus << endl;
cout << defender.get_name() << " rolls an defense bonus of " << defbonus << endl;
int total_att=attbonus+attacker.get_attackLevel();
int total_def=defbonus+defender.get_defLevel();
int damage;
if(total_att>total_def)
{
int roll1=d6.roll();
int roll2=d6.roll();
int roll3=d6.roll();
damage=roll1+roll2+roll3;
cout << "The attack hits dealing 3-D6 damage!" << endl;
cout << "The rolls are: " << roll1 << " " << roll2 << " " << roll3 << " totalling: " << damage << " damage!" << endl;
defender.reduceHP(damage);
if(defender.get_hp() <=0 )
{
returnValue=true;
}
else
{
returnValue=false;
cout << defender.get_name() << " has " << defender.get_hp() << " hit points left." << endl;
}
}
else
{
damage=0;
cout << "The attack is missed!" << endl;
}
return returnValue;
}
示例2: play
void Colosseum::play(Pokemon& p1, Pokemon& p2) //function that determines who goes first, when game is over, and constraints the game to 10 rounds
{
int hp;
Dice d;
int j=d.roll();
string position;
if(j==1)
{
position="first";
}
else
{
position="second";
}
cout << p1.get_name() << " rolls a " << j << " and goes " << position << endl;
if(position=="first")
{
for(int i=1; i<11; i++)
{
cout << "Round " << i << "!" << endl;
if(attack(p1,p2)==true)
{
cout << p2.get_name() << " has been defeated!" << endl;
break;
}
if(attack(p2,p1)==true)
{
cout << p1.get_name() << " has been defeated!" << endl;
break;
}
if(i==10)
{
cout << "Game Over. It's a draw!" << endl;
}
}
}
else
{
for(int i=1; i<11; i++)
{
cout << "Round " << i << "!" << endl;
if(attack(p2,p1)==true)
{
cout << p1.get_name() << " has been defeated!" << endl;
break;
}
if(attack(p1,p2)==true)
{
cout << p2.get_name() << " has been defeated!" << endl;
break;
}
if(i==10)
{
cout << "Game Over. It's a draw!" << endl;
}
}
}
}