本文整理汇总了C++中Spell::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Spell::getName方法的具体用法?C++ Spell::getName怎么用?C++ Spell::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spell
的用法示例。
在下文中一共展示了Spell::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_spells
/*
* format:
* $owner-uid;nr-spells;spell1-name;spell1-uid;spell2-name;spell2-uid;...;\n
*/
void instance::draw_spells(puppet_ptr inPuppet, int inNrOfSpells) {
if (!inPuppet)
inPuppet = active_puppet_;
const int mMaxSpellsInHand = 6;
drawn_spells_.str("");
drawn_spells_ << "[draw];" << inNrOfSpells << "\n";
drawn_spells_ << "$" << inPuppet->getUID() << ";";
// create nrSpellsPerTurn spells from the hero's deck
Deck* lDeck = inPuppet->getDeck();
int i;
for (i=0; i< inNrOfSpells; ++i) {
Spell* lSpell = lDeck->drawSpell();
// assign UID and attach to puppet
lSpell->setUID(generate_uid());
inPuppet->attachSpell(lSpell);
pass_to_lua("Spells.onDrawSpell", 2, "Pixy::Puppet", inPuppet.get(), "Pixy::Spell", lSpell);
drawn_spells_ << lSpell->getName() << ";" << lSpell->getUID() << ";";
lSpell = 0;
}
drawn_spells_ << "\n";
// tell it to drop some spells if its hand is overflown
drawn_spells_ << "[drop];";
int nrOverflow = inPuppet->nrSpellsInHand() - mMaxSpellsInHand;
//~ std::cout << "Puppet has " << inPuppet->nrSpellsInHand() << " spells in hand, an overflow of= " << nrOverflow << "\n";
if (nrOverflow > 0) {
drawn_spells_ << nrOverflow << "\n$" << inPuppet->getUID() << ";";
} else
drawn_spells_ << 0;
Entity::spells_t const& lHand = inPuppet->getHand();
while (inPuppet->nrSpellsInHand() > mMaxSpellsInHand) {
Spell* lSpell = lHand.front();
drawn_spells_ << lSpell->getUID() << ";";
pass_to_lua("Spells.onDropSpell", 2, "Pixy::Puppet", inPuppet.get(), "Pixy::Spell", lSpell);
inPuppet->detachSpell(lSpell->getUID());
lSpell = 0;
}
drawn_spells_ << "\n";
//~ log_->infoStream() << "sending drawn spells to Puppet " << inPuppet->getName();
std::cout << "drawn spells:\n" << drawn_spells_.str() << "\n";
// broadcast the data
Event evt(EventUID::DrawSpells, EventFeedback::Ok, Event::NoFormat);
evt.setProperty("Data", drawn_spells_.str());
broadcast(evt);
}
示例2: setSpellOverview
void MainWindow::setSpellOverview(const Spell &spell)
{
ui->listOverview->clear();
ui->listOverview->addItem("Id: " + QString::number(spell.getId()));
ui->listOverview->addItem("Name: " + spell.getName());
ui->listOverview->addItem("Rank: " + spell.getRank());
ui->listOverview->addItem("Description: " + spell.getDescription());
ui->listOverview->addItem("Tooltip: " + spell.getTooltip());
ui->listOverview->addItem("School: " + spell.getSchool());
ui->listOverview->addItem("Range: from " + QString::number(spell.getMinRange())
+ " to " + QString::number(spell.getMaxRange()));
ui->listOverview->addItem("Dispel: " + spell.getDispel());
ui->listOverview->addItem("Mechanic: " + spell.getMechanic());
}
示例3: checkLinkSpell
void Skill::checkLinkSpell() {
unsigned int i=0;
while(i<m_describe.size()-7) {
if(m_describe.substr(i, 6) == "SPELL(") {
unsigned int j=i+6;
while(j<m_describe.size() && m_describe.at(j) != ')')
j++;
if(j<m_describe.size()) {
std::cout << "=> " << m_describe.substr(i+6, i+6-j) << std::endl;
Spell* spell = SpellReader::get(util::Cast::stringToInt(m_describe.substr(i+6, i+6-j)));
if(spell != NULL) {
m_describe = m_describe.substr(0, i)+"<br/><br/><color=sp>"+spell->getName()+" :</color><br/>"+spell->getContents()+m_describe.substr(j+1);
}
return;
}
}
i++;
}
}
示例4: on_cast_spell
void instance::on_cast_spell(const Event& inEvt) {
if (!inEvt.hasProperty("Spell")) {
Event evt(inEvt);
reject(evt);
return;
}
// find the spell object
Spell* lSpell;
try {
lSpell = get_spell(convertTo<int>(inEvt.getProperty("Spell")));
} catch (invalid_uid& e) {
// reject the event
log_->errorStream() << "couldn't find requested Spell with id " << inEvt.getProperty("Spell");
Event evt(inEvt);
reject(evt);
return;
}
Entity* lCaster = lSpell->getCaster();
assert(lCaster && lSpell);
log_->debugStream() << "spell cast: " << lSpell->getUID() << "#" << lSpell->getName();
log_->debugStream() << "caster: " << lCaster->getUID() << "#" << lCaster->getName();
// allow only ALL or CASTING spells to be cast by active puppets
if (lSpell->getPhase() != BLOCKING && active_puppet_->getUID() != lCaster->getOwner()->getUID())
{
Event evt(inEvt);
return reject(evt);
}
// blocking spells can only be cast when the active is not the caster
else if (lSpell->getPhase() == BLOCKING && active_puppet_->getUID() == lCaster->getOwner()->getUID())
{
Event evt(inEvt);
return reject(evt);
}
Entity* lTarget = 0;
if (inEvt.hasProperty("T")) {
try {
// is the target a puppet?
lTarget = get_puppet(convertTo<int>(inEvt.getProperty("T"))).get();
log_->debugStream() << "target: " << lTarget->getUID() << "#" << lTarget->getName();
} catch (invalid_uid& e) {
try {
// a unit?
lTarget = get_unit(convertTo<int>(inEvt.getProperty("T")));
log_->debugStream() << "target: " << lTarget->getUID() << "#" << lTarget->getName();
} catch (invalid_uid& e) {
// invalid UID
log_->errorStream() << "couldn't find spell target with id " << inEvt.getProperty("T");
Event evt(inEvt);
reject(evt);
return;
}
}
assert(lTarget);
lSpell->setTarget(lTarget);
} else {
// if the spell requires a target, it must be given
#ifdef PARANOID
assert(!lSpell->requiresTarget());
#else
// gracefully reject the event
if (lSpell->requiresTarget())
{
log_->errorStream()
<< "an invalid spell request#" << lSpell->getUID()
<< "; target is required but not given";
Event e(inEvt);
return reject(e);
}
#endif
// otherwise, the spell's target is the caster itself
lSpell->setTarget(lCaster);
}
// verify the caster having enough resources to cast the spell
{
bool valid = true;
if (lCaster->getRank() == PUPPET)
{
if (lSpell->getCostWP() > ((Puppet*)lCaster)->getWP())
valid = valid && false;
// heroes can't have less than 1 channel
if (lSpell->getCostChannels() >= ((Puppet*)lCaster)->getChannels())
valid = valid && false;
}
if (lSpell->getCostHP() > lCaster->getHP())
valid = valid && false;
if (!valid)
{
if (lCaster->getRank() == PUPPET)
{
//.........这里部分代码省略.........