summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-pick.h
blob: c9dbc03fdb43634fdac933a9ab3e13a722df1e0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
 * @file
 * @brief Functions for picking from lists of spells.
**/

#ifndef SPL_PICK_H
#define SPL_PICK_H

#include "externs.h"
#include "random-pick.h"

#define spell_entry random_pick_entry<spell_type>
typedef bool (*spell_pick_vetoer)(spell_type);

// Subclass a spell picker using the random_picker template
class spell_picker : public random_picker<spell_type, NUM_SPELLS>
{
public:
    spell_picker(spell_pick_vetoer _veto = nullptr) : veto_func(_veto) { };

    spell_type pick_with_veto(const spell_entry *weights, int level,
                              spell_type none,
                              spell_pick_vetoer veto_func = nullptr);

    virtual bool veto(spell_type spell);

protected:
    spell_pick_vetoer veto_func;
};

#endif