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

#ifndef EAGLE0_BUILDBRIDGECOMMAND_HPP
#define EAGLE0_BUILDBRIDGECOMMAND_HPP

#include <utility>

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

namespace shardok {

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

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

    const ActionCost cost;
    const UnitId actorId;
    const Coords target;
    const Terrain targetTerrain;
    const bool hasNearbyForest;
    const int agilityXp;
    const int strengthXp;
    int minimumKnowledgeAfter;

public:
    BuildBridgeCommand(
            const ActionCost& cost,
            PlayerId playerId,
            UnitId actorId,
            Coords target,
            const Terrain& targetTerrain,
            bool hasNearbyForest,
            int agilityXp,
            int strengthXp,
            int opponentKnowledgeIncrease)
        : ShardokCommand(playerId),
          cost(cost),
          actorId(actorId),
          target(std::move(target)),
          targetTerrain(std::move(targetTerrain)),
          hasNearbyForest(hasNearbyForest),
          agilityXp(agilityXp),
          strengthXp(strengthXp),
          minimumKnowledgeAfter(opponentKnowledgeIncrease){};

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

    ~BuildBridgeCommand() override = default;

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

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

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

#endif  // EAGLE0_BUILDBRIDGECOMMAND_HPP
