本文整理汇总了C++中Hero::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Hero::getName方法的具体用法?C++ Hero::getName怎么用?C++ Hero::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hero
的用法示例。
在下文中一共展示了Hero::getName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: combat
void Game::combat(Hero& newHero,Monster& newMonster)
{
int playerDamage,monsterDamage;
while(true)
{
playerDamage=newMonster.getDamage()-newHero.getBlock();
cout<<endl<<newMonster.getName()<<" damages you for "<<playerDamage<<" HP...\n";
newHero.takeDamage(playerDamage);
if(newHero.getCurHP()<=0)
gameEnd();
cout<<newMonster.getName()<<" HP: "<<newMonster.getHP()<<"\t\t"<<newHero.getName()<<" HP: "<<newHero.getCurHP();
_getch();
monsterDamage=newHero.getMeleeDamage();
newMonster.takeDamage(monsterDamage);
if(newMonster.getHP()<=0)
{
cout<<endl<<"You deliver the killing blow to "<<newMonster.getName()<<"\n";
newHero.updateXP(newMonster.getLevel());
return;
}
cout<<endl<<"You damage "<<newMonster.getName()<<" for "<<monsterDamage<<" HP...\n";
cout<<newMonster.getName()<<" HP: "<<newMonster.getHP()<<"\t\t"<<newHero.getName()<<" HP: "<<newHero.getCurHP();
_getch();
}
}
示例2: battle
//conducts the battle between player and enemy also increments or decrements gold
void battle(KillCount& kMap, Hero<int> &hero, Enemy<int> &e, int &gold){
cout << endl;
//show enemy stats and players stats before player chooses weapon
cout << "Now battling " << e.getName() << " " << e.getID() << " carrying "
<< e.getEgold() << " gold" << endl;
cout << "Enemy has " << e.getAttk() << " attack" << endl;
cout << hero.getName() << " has " << hero.getAttack() << endl;
//player attack after the have chosen a weapon
int heroBattleAttk = hero.getAttack() + hero.boost();
//show player attack after they have chosen a weapon
cout << hero.getName() << " Attack become " << heroBattleAttk << endl;
if(e.getAttk() > heroBattleAttk){
//if enemy has more attack player loses gold equal to amount carried by enemy
cout << "You have lost battle " << e.getEgold() << " gold lost" << endl;
gold -= e.getEgold();
cout << "Gold count now: " << gold << endl;
}else if(e.getAttk() < heroBattleAttk){
//if player has more attack than enemy player gains gold gold carried by enemy
cout << "You have won battle " << e.getEgold() << " gold gained" << endl;
gold += e.getEgold();
kMap.incrementCount(e.getName());
cout << "Gold count now: " << gold << endl;
}else{
//if tie no gold won or lost
cout << "Battle is a tie no gold gained or lost" << endl;
gold +=0;
cout << "Gold count now: " << gold << endl;
}
}
示例3: _insertHero
bool DataBase::_insertHero(const Hero &hero) {
QSqlQuery query(_db);
query.prepare("insert into Heroes (hero_id, name) values(?, ?)");
query.addBindValue(hero.getId());
query.addBindValue(hero.getName());
return query.exec();
}
示例4: EnterShop
void PotionShop::EnterShop(Hero& hero)
{
cout << "Welcome "<< hero.getName()<< ", to the Claimh Solais Potion Shop\n";
PotionShop Potion;
Potion.potionShop(hero);
//Potion.potionShop(hero);
//MainShop *potionShop = &Potion;
// calling soldierShop
//potionShop->potionShop(hero);
}
示例5: EnterShop
void ArcherWeapons::EnterShop(Hero& hero)
{
cout << "Welcome "<< hero.getName()<< ", to the Claimh Solais Bow Shop\n";
ArcherWeapons bow;
bow.ArcherShop(hero);
//ArcherWeapons Bow;
//Bow.ArcherShop(hero);
//MainShop *bowShop = &Bow;
// calling soldierShop
//bowShop->EnterShop(hero);
}
示例6: EnterShop
void MageArmor::EnterShop(Hero& hero)
{
cout << "Welcome "<< hero.getName()<< ", to the Claimh Solais Armor Shop\n" << endl;
MageArmor armor_soldier;
armor_soldier.MageArmor_Shop(hero);
//MageArmor Sword;
//Sword.MageArmor_Shop(hero);
//MainShop *MageArmor = &Sword;
// calling MageArmor_Shop
//MageArmor->EnterShop(hero);
}//Instance automatically deleted here at end of scope
示例7: intro
//introduction for the game explains objective and game play
void intro(Hero<int> &h, int gold){
cout <<"OK " << h.getName() << " your adventure begins here" << endl;
cout << "Your interdimensional transport ship has run out of fuel(gold) in a \n" <<
"mysterious dimension you must collect at least 35 gold pieces in order \n" <<
"to make the trip home" << endl;
cout << "Collect gold by defeating enemies in the various areas" << endl;
cout << "winning gives you their gold losing removes gold equal to what the enemy "
<< "was carrying" << endl;
cout << "your base attack is: " << h.getAttack() << endl;
cout << "your base special attack is: " << h.getSpecial() << endl;
cout << "you have " << gold << " to start collect at leat 35 to win" << endl;
cout << "if no gold remaining you lose" << endl;
cout << endl;
}
示例8: getNextCreaturePos
Vector2D GameState::getNextCreaturePos(){
//get current creature
Creature* c = plyr.getCreature();
if (!c){
//TODO return any creature
cerr << "not set";
return Vector2D(-1,-1);
}
bool currFound = false;
Hero* heros = wrld.getHeros();
for (int i = 0; i < wrld.getHeroSize(); i++){
if (wrld.getStarts()[i] != Vector2D(-1,-1))
continue;
Hero h = heros[i];
if (h.getName() == c->getName() && h.getPlayer() == c->getPlayer()){
//found current
currFound = true;
continue;
}
if (currFound && h.getPlayer() == plyr.getName()){
//found next
return h.getPosition();
}
}
vector<Monster*>& monsters = wrld.getMonsters();
for (unsigned i = 0; i < monsters.size(); i++){
Monster* m = monsters[i];
if (m->getName() == c->getName() && m->getPlayer() == c->getPlayer()){
//found current
currFound = true;
continue;
}
if (currFound && m->getPlayer() == plyr.getName()){
//found next
return m->getPosition();
}
}
for (int i = 0; i < wrld.getHeroSize(); i++){
if (wrld.getStarts()[i] != Vector2D(-1,-1))
continue;
Hero h = heros[i];
if (h.getName() == c->getName() && h.getPlayer() == c->getPlayer()){
//found current
currFound = true;
continue;
}
if (currFound && h.getPlayer() == plyr.getName()){
//found next
return h.getPosition();
}
}
for (unsigned i = 0; i < monsters.size(); i++){
Monster* m = monsters[i];
if (m->getName() == c->getName() && m->getPlayer() == c->getPlayer()){
//found current
currFound = true;
continue;
}
if (currFound && m->getPlayer() == plyr.getName()){
//found next
return m->getPosition();
}
}
//nothing suitable found, so the next is the old
return c->getPosition();
}
示例9: getName
bool Hero::operator<=(Hero h) {
return getName() <= h.getName();
}