//
// Created by Dan Crosby on 5/31/20.
//

#ifndef EAGLE0_DISMISSUNITCOMMAND_HPP
#define EAGLE0_DISMISSUNITCOMMAND_HPP

#include <utility>

#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/protobuf/net/eagle0/shardok/common/terrain.pb.h"

namespace shardok {

using TerrainProto = net::eagle0::shardok::common::Terrain;

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

    const UnitId actingUnitId;
    const UnitId dismissedUnitId;
    const PercentileRollOdds odds;

public:
    DismissUnitCommand(
            const PlayerId playerId,
            const UnitId actingUnitId,
            const UnitId dismissedUnitId,
            PercentileRollOdds odds)
        : ShardokCommand(playerId),
          actingUnitId(actingUnitId),
          dismissedUnitId(dismissedUnitId),
          odds(std::move(odds)){};

    ~DismissUnitCommand() override = default;

    [[nodiscard]] auto ExecuteWithRoll(const GameStateW& currentState, double roll) const
            -> vector<ActionResult>;

    auto GetCommandType() const -> CommandType override {
        return net::eagle0::shardok::common::DISMISS_UNIT_COMMAND;
    }

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

}  // namespace shardok

#endif  // EAGLE0_DISMISSUNITCOMMAND_HPP
