#include "Player/Enemy.h"

#include <Ship/Ship.h>

#include <algorithm>
#include <functional>
#include <iostream>

Enemy::Enemy(const std::string& name, std::unique_ptr<Ship>&& ship, std::unique_ptr<DifficultLvlStrategy<Ship, int>>&& strategy):
    _name(name), _ship(std::move(ship)), _strategy(std::move(strategy)) {}

void Enemy::attack(Ship& playerShip) {
    std::cout << "Player: " << _name << " attack ship: " << playerShip.name() << '\n';
    if (const auto damage = _strategy->handle(playerShip)) {
        std::cout << "Dealed damage: " << damage << '\n';
    } else {
        std::cout << "Missed\n";
    }
}
