//
// Created by Dan Crosby on 3/11/20.
//

#ifndef EAGLE0_BRAVEWATERCOMMAND_HPP
#define EAGLE0_BRAVEWATERCOMMAND_HPP

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

namespace shardok {
class BraveWaterCommand : public ShardokCommand {
protected:
    [[nodiscard]] auto InternalExecuteWithRoll(
            const GameStateW &currentState,
            const std::shared_ptr<RandomGenerator> &generator,
            optional<int32_t> roll) const -> vector<ActionResult> override;

    const ActionCost cost;
    const UnitId actorId;
    const std::optional<UnitId> ambusherId;
    const Coords target;

    const PercentileRollOdds successOdds;
    const double maxLossPercentage;

    const SettingsGetter settings;

public:
    BraveWaterCommand(
            const ActionCost &cost,
            PlayerId playerId,
            UnitId actorId,
            const std::optional<UnitId> &ambusherId,
            const Coords &target,
            PercentileRollOdds successOdds,
            double maxLossPercentage,
            const SettingsGetter &settingsGetter);

    [[nodiscard]] auto ExecuteWithRolls(
            double successRoll,
            double lossesRoll,
            double ambusherRoll,
            const GameStateW &currentState,
            const std::shared_ptr<RandomGenerator> &generator) const -> vector<ActionResult>;

    ~BraveWaterCommand() override = default;

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

    [[nodiscard]] auto CanUseClientRoll() const -> bool override { return true; }
    [[nodiscard]] auto GetCommandProto() const -> CommandProto override;

    [[nodiscard]] auto HasOdds() const -> bool override { return true; }
    [[nodiscard]] auto GetOddsPercentile() const -> int32_t override;
};
}  // namespace shardok

#endif  // EAGLE0_BRAVEWATERCOMMAND_HPP
