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

#ifndef MeteorCastAction_hpp
#define MeteorCastAction_hpp

#include <utility>

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

namespace shardok {

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

class MeteorCastAction : public ShardokAction {
private:
    // Appends new results to vector passed in
    auto PerformOneActorCast(
            vector<ActionResult>& results,
            const Unit* actorBefore,
            GameStateW& runningGameState,
            const std::shared_ptr<RandomGenerator>& generator) const -> GameStateW;

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

    const vector<UnitId> actorIds;
    const GameStateW startingGameState;
    const SettingsGetter settings;
    [[nodiscard]] auto MeteorBaseDamage() const -> double {
        return settings.Backing().meteor_base_damage();
    };
    [[nodiscard]] auto MeteorDirectFireBaseChance() const -> double {
        return settings.Backing().meteor_direct_fire_base_chance();
    }
    [[nodiscard]] auto MeteorSplashFireBaseChance() const -> double {
        return settings.Backing().meteor_splash_fire_base_chance();
    }
    [[nodiscard]] auto MeteorStructureDamage() const -> double {
        return settings.Backing().meteor_structure_damage();
    }
    [[nodiscard]] auto MeteorFrozenReduction() const -> double {
        return settings.Backing().meteor_frozen_integrity_reduced();
    }
    [[nodiscard]] auto MeteorSnowReduction() const -> double {
        return settings.Backing().meteor_snow_integrity_reduced();
    }
    [[nodiscard]] auto MeteorSplashFactor() const -> double {
        return settings.Backing().meteor_splash_factor();
    }

    [[nodiscard]] auto FallInWaterDamagePerTroop() const -> double {
        return settings.Backing().fall_in_water_damage_per_troop();
    }
    [[nodiscard]] auto FallInWaterBaseEscapeOdds() const -> int {
        return settings.Backing().fall_in_water_base_escape_odds();
    }

public:
    MeteorCastAction(GameStateW gameState, vector<UnitId> actors, const SettingsGetter& settings)
        : actorIds(std::move(actors)),
          startingGameState(std::move(gameState)),
          settings(settings){};
};
}  // namespace shardok

#endif /* MeteorCastAction_hpp */
