From 2a9f262e6db5906db445d465e500d7ba8c90fab3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 5 May 2021 09:44:50 -0400 Subject: Implemented additional commands --- src/spellcasting.cc | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/spellcasting.cc') 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::create(const json& data) { + return shared_ptr(new SlotLevel(data)); + } + + vector> Spellcasting::getSpells() const { + vector> 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 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(); -- cgit v1.2.3