#include "witch.h"

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

witch::witch(RNG *rng, const feature enabled_features, const position &pos,
             const int gen_room_num):
        enemy_base{rng, enabled_features, WITCH, pos, gen_room_num, "Z"} {}

const char *witch::get_race_name() const {
        return "Witch";
}

long_result witch::attack(character *ch) {
        auto res = ch->get_hit(this, ATK, base_hit_rate);

        if (res.res == HIT && rng->trial(POTION_RATE)) {
                potion_type type =
                        static_cast<potion_type>(rng->rand_under(
                                        (enabled_features & FEATURE_EXTRA_STUFF) ?
                                        POTION_TYPE_CNT :
                                        DEFAULT_POTION_TYPE_CNT));
                auto npotion = new_potion(type, {0, 0});
                res.msg += std::string("Z's potion of ") +
                           npotion->get_name() + " spills onto PC. ";
                static_cast<player_base *>(ch)->set_potion_known(
                        npotion->get_type());
                ch->apply_effect(std::move(npotion));
        }

        return res;
}
