//
//  ReinforceCommand.hpp
//  eagle0
//
//  Created by Dan Crosby on 12/30/19.
//  Copyright © 2019 none. All rights reserved.
//

#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_REINFORCE_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_REINFORCE_COMMAND_HPP

#include <utility>

#include "src/main/cpp/net/eagle0/shardok/library/ActionCost.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"

namespace shardok {

using Unit = net::eagle0::shardok::storage::fb::Unit;

class ReinforceCommand : public ShardokCommand {
protected:
    auto InternalExecute(
            const GameStateW& currentState,
            const std::shared_ptr<RandomGenerator>& generator) const
            -> vector<ActionResult> override;

    const ActionCost cost;
    const UnitId actingUnitId;
    const UnitId joiningUnitId;
    const Coords location;

public:
    ReinforceCommand(
            const ActionCost& cost,
            const PlayerId playerId,
            const UnitId actingUnitId,
            const UnitId joiningUnitId,
            const Coords reinforcePosition)
        : ShardokCommand(playerId),
          cost(cost),
          actingUnitId(actingUnitId),
          joiningUnitId(joiningUnitId),
          location(reinforcePosition) {}

    ~ReinforceCommand() override = default;

    [[nodiscard]] auto GetCommandType() const -> CommandType override {
        return net::eagle0::shardok::common::REINFORCE_COMMAND;
    }

    [[nodiscard]] auto GetCommandProto() const -> CommandProto override;

    [[nodiscard]] auto IsRequiredToEndTurn() const -> bool override { return false; }
    [[nodiscard]] auto CanBeFollowUp() const -> bool override { return true; }
    [[nodiscard]] auto CanDoWithLowMorale() const -> bool override { return true; }
    [[nodiscard]] auto CanDoWhileStunned() const -> bool override { return false; }
    [[nodiscard]] auto CanDoWithLowVigor() const -> bool override { return false; }
    [[nodiscard]] auto CanDoAfterMovingIntoZoc() const -> bool override { return false; }

    [[nodiscard]] int GetActorUnitId() const override { return actingUnitId; }
    [[nodiscard]] MapIndex GetTargetRow() const override { return location.row(); }
    [[nodiscard]] MapIndex GetTargetColumn() const override { return location.column(); }
};
}  // namespace shardok

#endif  // EAGLE0_SHARDOK_LIBRARY_COMMANDS_REINFORCE_COMMAND_HPP
