#include "Battle/Attack.h"

#include <Player/Player.h>
#include <Ship/Ship.h>

#include <iostream>

Action::Status Attack::operator()(Player* player, Ship* enemyShip) {
    const int damage = player->attack(*enemyShip);
    std::cout << "Player ship: " << player->getShip().name() << " attack ship: " << enemyShip->name() << '\n';
    if (damage) {
        std::cout << "Dealed damage: " << damage << '\n';
    } else {
        std::cout << "Missed\n";
    }

    if (enemyShip->durability() <= 0) {
        return Status::Defeated;
    }

    return Status::Nothing;
}
