//
//  MeleeCommand.hpp
//  eagle0_engine
//
//  Created by Dan Crosby on 12/29/18.
//  Copyright © 2018 none. All rights reserved.
//

#ifndef MeleeCommand_hpp
#define MeleeCommand_hpp

#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"

namespace shardok {
class CombatUtils;

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

class MeleeCommand : public ShardokCommand {
private:
    [[nodiscard]] auto ExecuteWithRolls(
            const GameStateW& currentState,
            double ambushRoll,
            double attackerRoll,
            double defenderRoll) const -> vector<ActionResult>;

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 SettingsGetter settings;
    const UnitId attackerId;
    const UnitId defenderId;
    const Coords defenderLocation;
    const PercentileRollOdds ambushOdds;

public:
    MeleeCommand(
            const ActionCost& cost,
            const SettingsGetter& settingsGetter,
            PlayerId playerId,
            UnitId attackerId,
            UnitId defenderId,
            const Coords& defenderLocation,
            PercentileRollOdds ambushOdds);

    ~MeleeCommand() override = default;

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

    auto GetCommandProto() const -> CommandProto override;

    auto CanUseClientRoll() const -> bool override { return true; }
};
}  // namespace shardok

#endif /* MeleeCommand_hpp */
