#include "Player/EnemyEasyDifficultLvlStrategy.h"

#include "Ship/Ship.h"

std::random_device EnemyEasyDifficultLvlStrategy::_rd{};

EnemyEasyDifficultLvlStrategy::EnemyEasyDifficultLvlStrategy()
    : _seed(_rd()) {}

int EnemyEasyDifficultLvlStrategy::handle(Ship& ship) const {
    std::uniform_int_distribution<int> dice(1, 20);
    int multiplier = 1;
    const int res = dice(_seed);

    if (res < 5) {
        // miss
        return 0;
    } else if (res > 19) {
        // criticall
        multiplier = 2;
    }

    std::uniform_int_distribution<int> damage(25, 50);
    const int total = damage(_seed) * multiplier;
    ship.takeDamage(total);

    return total;
}
