#include "leprechaun.h"

#include "constants.h"
#include "player.h"
#include "level.h"

leprechaun::leprechaun(RNG *rng, const feature enabled_features,
                       const position &pos,
                       const int gen_room_num):
        enemy_base{rng, enabled_features, LEPRECHAUN, pos, gen_room_num, "l"},
        gold_cnt{STARTING_GOLD} {}

const char *leprechaun::get_race_name() const {
        return "Leprechaun";
}

long_result leprechaun::attack(character *ch) {
        long_result res;

        if (static_cast<player_base * >(ch)->get_gold() < STEAL_GOLD) {
                res = ch->get_hit(this, BOOSTED_ATK, base_hit_rate);
                res.msg = "l is angered because PC is too poor. " + res.msg;
        } else {
                res = ch->get_hit(this, ATK, base_hit_rate);

                if (res.res == HIT) {
                        res.msg += "l steals " + std::to_string(STEAL_GOLD) +
                                   " pieces of gold from PC. ";
                        static_cast<player_base *>(ch)->add_gold(-STEAL_GOLD);
                        gold_cnt += STEAL_GOLD;
                }
        }

        return res;
}

int leprechaun::dies(level *lvl) {
        lvl->add_gold(gold{pos, gold_cnt});
        return 0;
}
