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

#ifndef FallIntoWaterAction_hpp
#define FallIntoWaterAction_hpp

#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/unit/Unit.hpp"
#include "src/main/flatbuffer/net/eagle0/shardok/storage/hex_map.hpp"

namespace shardok {

using GameState = net::eagle0::shardok::storage::fb::GameState;
using HexMap = net::eagle0::shardok::storage::fb::HexMap;
using Unit = net::eagle0::shardok::storage::fb::Unit;
using WeatherFb = net::eagle0::shardok::storage::fb::Weather;
using Coords = net::eagle0::shardok::storage::fb::Coords;

class FallIntoWaterAction : public ShardokAction {
private:
    struct AdjacentWithTerrain {
        Coords adjacentCoords;
        Terrain terrain;

        AdjacentWithTerrain(const Coords& adjacentCoords, const Terrain& terrain)
            : adjacentCoords(adjacentCoords),
              terrain(terrain) {}
    };

    static auto AdjacentsWithTerrain(
            const Coords& location,
            const GameState* gameState,
            PlayerId playerId) -> vector<AdjacentWithTerrain>;

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

    const UnitId fallerId;
    const SettingsGetter settings;
    const double penetratingColdDamagePerTroop;
    const int baseEscapeOdds;

public:
    FallIntoWaterAction(
            UnitId fallerId,
            const SettingsGetter& settingsGetter,
            double penetratingColdDamagePerTroop,
            int baseEscapeOdds);
};
}  // namespace shardok

#endif /* FallIntoWaterAction_hpp */
