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

#ifndef EAGLE0_STARTFIRECOMMAND_HPP
#define EAGLE0_STARTFIRECOMMAND_HPP

#include <utility>

#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/settings/GameSettings.hpp"
#include "src/main/flatbuffer/net/eagle0/shardok/storage/unit.hpp"

namespace shardok {

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

class StartFireCommand : public ShardokCommand {
private:
    [[nodiscard]] auto ExecuteWithRoll(double roll) const -> vector<ActionResult>;

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

    const SettingsGetter settings;
    const Unit* actor;
    const Coords target;
    const Terrain targetTerrain;
    const PercentileRollOdds odds;

public:
    StartFireCommand(
            const SettingsGetter& getter,
            const Unit* actor,
            Coords target,
            Terrain targetTerrain,
            PercentileRollOdds odds);

    ~StartFireCommand() override = default;

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

    auto GetCommandProto() const -> CommandProto override;

    [[nodiscard]] auto CanBeFollowUp() const -> bool override { return true; }
    [[nodiscard]] auto CanDoWithLowMorale() const -> bool override { return false; }
    [[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]] auto IsRequiredToEndTurn() const -> bool override { return false; }
    [[nodiscard]] auto HasOdds() const -> bool override { return true; }
    [[nodiscard]] auto GetOddsPercentile() const -> int32_t override;
};
}  // namespace shardok

#endif  // EAGLE0_STARTFIRECOMMAND_HPP
