コード例 #1
0
ファイル: player_spells_handling.cpp プロジェクト: Aksej/ia
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));
    }
}
コード例 #2
0
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)));
    }
}
コード例 #3
0
ファイル: spells.cpp プロジェクト: tmo35/ia
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]);
}