本文整理汇总了C++中Spell::getTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ Spell::getTitle方法的具体用法?C++ Spell::getTitle怎么用?C++ Spell::getTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spell
的用法示例。
在下文中一共展示了Spell::getTitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
///
///Performs square quest
///
void Tavern::execute(AdventureCardDeck* d, SpellDeck* s, PurchaseDeck* p, Character* c, QTextEdit* txtLog){
int choice = rand() % 6 + 1;
Spell* temp;
switch(choice){
case 1: txtLog->append("\nYou get blind drunk and collapse in a corner. Waking up a few hours\nlater you find yourself unharmed and your belongings intact.\nYou were lucky this time.");
break;
case 2: txtLog->append("\nYou get tipsy and get into a fight with a farmer. Though you swing wildly and without coordination,\nyou manage to knock him out cold. Gain 1 Strength from the battle.");
c->setStrength(c->getStrength() + 1);
break;
case 3: txtLog->append("\nYou gamble with a peddler on a game of dice but lose the wager.\nLose 1 Gold piece.");
c->setGold(c->getGold() - 1);
if (c->getGold() < 0)
c->setGold(0);
break;
case 4: txtLog->append("\nYou gamble with a peddler on a game of dice and win the wager.\nGain 2 Gold pieces.");
c->setGold(c->getGold() + 2);
break;
case 5:
temp = s->drawCard();
if(s != NULL){
if (c->addObject(temp))
txtLog->append(QString::fromStdString("\nA wizard teaches you the Spell: " + temp->getTitle() + "\nIt has been added to your Inventory."));
else
txtLog->append(QString::fromStdString("\nA wizard offers to teach you the Spell: " + temp->getTitle() + " but you already know it."));
}
else
txtLog->append("\nA wizard offers to teach you a Spell, but there are none left in the Spell Deck.");
break;
case 6:
if (c->addObject((new WeaponFactory())->getClass("Axe")))
txtLog->append("\nYou casually relax and find an Axe hidden under a shaded table.\nIt has been added to your Inventory.");
else
txtLog->append("\nYou casually relax and find an Axe hidden under a shaded table.\nYou already have a perfectly good Axe so you leave it there.");
break;
}
}
示例2: useSpell
//Spell stuff
void GameEngine::useSpell(Point mouseLoc) {
Spell spell = invLog.getSpell(mouseLoc);
if (spell.isUnlocked()) {
if (hero->getMana() < spell.getCost())
log.registerEvent("Not enough mana!");
else {
log.registerEvent(spell.getTitle() + " activated!");
Point start = hero->getLoc() + Point(-1, -1);
Point end = hero->getLoc() + Point(2, 2);
int type = spell.getSpellType();
switch (type) {
case 1: //Field of fire
{
spell.setTurnActivated(turns);
lib.loop_portion(start, end, [&](Point p) {
map[p.x()][p.y()].setSpell(spell);
});
break;
}
case 2: //Death Rattle
{
lib.loop_portion(start, end, [&](Point p) {
Actor* a = map[p.x()][p.y()].getActor();
if (a != NULL) {
Point relToHero = p - hero->getLoc();
Point d(p.x() + relToHero.x(), p.y() + relToHero.y());
a->doDMG(2);
if (a->getHP() <= 0)
killMonster(a->getLoc());
if (moveableCell(d)) {
map[p.x()][p.y()].setActor(NULL);
a->setLoc(d);
map[d.x()][d.y()].setActor(a);
}
}
});
break;
}
case 3: //Blessing of Katar
{
hero->changeHP(10);
break;
}
case 4: //Ice Block
{
spell.setTurnActivated(turns);
lib.loop_portion(start, end, [&](Point p) {
map[p.x()][p.y()].setSpell(spell);
});
break;
}
case 5: //Death Curse
{
spell.setTurnActivated(turns);
lib.loop_portion(start, end, [&](Point p) {
Actor* a = map[p.x()][p.y()].getActor();
if (a != NULL) {
a->setSpell(spell);
}
});
break;
}
case 6: //Fist of Katar
{
map[hero->getLoc().x()][hero->getLoc().y()].setSpell(spell);
break;
}
}
hero->changeMana(-spell.getCost());
lib.play("Spell" + to_string(spell.getSpellType()));
}
}
}