//
// Created by Dan Crosby on 4/10/20.
//

#ifndef EAGLE0_CHALLENGEDUELCOMMAND_HPP
#define EAGLE0_CHALLENGEDUELCOMMAND_HPP

#include <utility>

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

namespace shardok {

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

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

    const SettingsGetter settings;
    const UnitId challengerId;
    const UnitId defenderId;
    const Coords target;
    const int minimumKnowledgeAfter;

public:
    ChallengeDuelCommand(
            const SettingsGetter& settingsGetter,
            const PlayerId playerId,
            const UnitId challengerId,
            const UnitId defenderId,
            const Coords& target,
            const int professionKnowledgeBump)
        : ShardokCommand(playerId),
          settings(settingsGetter),
          challengerId(challengerId),
          defenderId(defenderId),
          target(target),
          minimumKnowledgeAfter(professionKnowledgeBump) {}

    ~ChallengeDuelCommand() override = default;

    [[nodiscard]] auto ExecuteWithRolls(
            const GameStateW& currentGameState,
            double acceptRoll,
            const std::shared_ptr<RandomGenerator>& generator) const -> vector<ActionResult>;

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

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

}  // namespace shardok

#endif  // EAGLE0_CHALLENGEDUELCOMMAND_HPP
