void load() { const int NR_SPELLS = save_handling::get_int(); for (int i = 0; i < NR_SPELLS; ++i) { const Spell_id id = Spell_id(save_handling::get_int()); known_spells_.push_back(spell_handling::mk_spell_from_id(id)); } }
void setup_from_save_lines(vector<string>& lines) { const int NR_SPELLS = to_int(lines.front()); lines.erase(begin(lines)); for (int i = 0; i < NR_SPELLS; ++i) { const int ID = to_int(lines.front()); lines.erase(begin(lines)); known_spells_.push_back(spell_handling::mk_spell_from_id(Spell_id(ID))); } }
Spell* random_spell_for_mon() { std::vector<Spell_id> bucket; for (int i = 0; i < int(Spell_id::END); ++i) { Spell* const spell = mk_spell_from_id(Spell_id(i)); if (spell->is_avail_for_all_mon()) { bucket.push_back(Spell_id(i)); } delete spell; } assert(!bucket.empty()); const int ELEMENT = rnd::range(0, bucket.size() - 1); return mk_spell_from_id(bucket[ELEMENT]); }