本文整理汇总了C++中Spell::setUID方法的典型用法代码示例。如果您正苦于以下问题:C++ Spell::setUID方法的具体用法?C++ Spell::setUID怎么用?C++ Spell::setUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spell
的用法示例。
在下文中一共展示了Spell::setUID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}