#ifndef __CHARACTERS_H__
#define __CHARACTERS_H__
#include <vector>
#include <string>
#include <memory>
#include <math.h>

#include "output.h"
#include "fraction.h"
#include "position.h"
#include "potions.h"
#include "gold.h"
#include "rng.h"

class level;
typedef unsigned int feature;
struct long_result;
enum result : int;

class character {
public:
        character(RNG *rng, const feature enabled_features,
                  const race &nrace, const position &pos); // fills out the starting stats

        virtual long_result attack(character *ch) = 0;
        virtual long_result get_hit(character *ch, const int tATK,
                                    const fraction &hit_rate) = 0;

        virtual void apply_effect(std::unique_ptr<potion> effect);

        // override for different types
        virtual void print(output *out) = 0;

        result calc_effects();
        void discard_level_effects();
        virtual void start_turn();

        virtual const char *get_race_name() const = 0;
        enum race get_race() const;
        position get_pos() const;
        virtual std::string get_abbrev() const = 0;
        void set_pos(const position &npos);

        bool is_dead() const;

protected:
        RNG *rng;

        const feature enabled_features;
        const enum race race;

        int HP;
        position pos;

        // IMPORTANT: keep track at turn time
        int ATK;
        int DEF;
        fraction base_hit_rate;

        potion_own_list effects;

private:
        void insert_effect(std::unique_ptr<potion> effect);
};

int calc_dmg(const int ATK, const int DEF);

typedef std::vector<character *> character_list;

character *get_ch_at(const position &pos, const character_list &chlist);

#endif
