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

#ifndef EAGLE0_LIGHTNINGBOLTCOMMAND_HPP
#define EAGLE0_LIGHTNINGBOLTCOMMAND_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/settings/GameSettings.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/unit/Unit.hpp"

namespace shardok {

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

    const SettingsGetter settings;
    const UnitId attackerId;
    const UnitId defenderId;
    const Coords defenderLocation;
    double damageCap;

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

    LightningBoltCommand(
            const SettingsGetter& settingsGetter,
            PlayerId playerId,
            UnitId attackerId,
            UnitId defenderId,
            const Coords& defenderLocation,
            double damageCap /* max percentage that can be lost */);

    ~LightningBoltCommand() override = default;

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

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

#endif  // EAGLE0_LIGHTNINGBOLTCOMMAND_HPP
