diff options
Diffstat (limited to 'src/spellcasting.cc')
-rw-r--r-- | src/spellcasting.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/spellcasting.cc b/src/spellcasting.cc index 9b39741..2606b53 100644 --- a/src/spellcasting.cc +++ b/src/spellcasting.cc @@ -8,6 +8,20 @@ using namespace std; namespace entry { + shared_ptr<SlotLevel> SlotLevel::create(const json& data) { + return shared_ptr<SlotLevel>(new SlotLevel(data)); + } + + vector<shared_ptr<Spell>> Spellcasting::getSpells() const { + vector<shared_ptr<Spell>> ret; + for(auto sl : getSlotLevels()) { + for(auto spell : sl->spells) { + ret.push_back(spell); + } + } + return ret; + } + string Spellcasting::getText(const creature::Creature& c) const { return genText(*this, c); } @@ -21,10 +35,15 @@ namespace entry { if(s.isInnate()) { text << " Spellcasting is innate."; } - int levelNumber = 0; - for(auto level : s.getSpellsBySlot()) { + int levelNumber = -1; + for(auto level : s.getSlotLevels()) { + levelNumber++; + // Skip if it's empty + if(level->numSlots == 0 && level->spells.empty()) { + continue; + } text << endl; - if(level.numSlots == 0) { + if(levelNumber == 0) { if(s.isInnate()) { text << " At will: "; } else { @@ -32,17 +51,16 @@ namespace entry { } } else { if(s.isInnate()) { - text << " " << level.numSlots << "/day each: "; + text << " " << level->numSlots << "/day each: "; } else { - text << " " << utils::toOrdinal(levelNumber) << " level (" << level.numSlots << " slots): "; + text << " " << utils::toOrdinal(levelNumber) << " level (" << level->numSlots << " slots): "; } } vector<string> names; - for(auto spell : level.spells) { - names.push_back(spell.getName()); + for(auto spell : level->spells) { + names.push_back(spell->getName()); } text << utils::join(names, ", "); - levelNumber++; } return text.str(); |