//
//  ChargeCommand.hpp
//  eagle0_engine
//
//  Created by Dan Crosby on 1/3/19.
//  Copyright © 2019 none. All rights reserved.
//

#ifndef ChargeAction_hpp
#define ChargeAction_hpp

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

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

class ChargeCommand : public ShardokCommand {
private:
    [[nodiscard]] auto ExecuteWithRolls(
            const GameStateW& currentState,
            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 defenderCoords;
    const AttackOrientation attackOrientation;

public:
    ChargeCommand(
            const ActionCost& cost,
            const SettingsGetter& settingsGetter,
            PlayerId playerId,
            UnitId attackerId,
            UnitId defenderId,
            const Coords& defenderLocation,
            AttackOrientation attackOrientation);
    ~ChargeCommand() override = default;

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

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

    [[nodiscard]] auto IsRequiredToEndTurn() const -> bool override { return true; }
    [[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 true; }
    [[nodiscard]] auto CanUseClientRoll() const -> bool override { return true; }
};
}  // namespace shardok

#endif /* ChargeAction_hpp */
