//
//  FireOutAction.hpp
//  eagle0_engine
//
//  Created by Dan Crosby on 2020/04/12.
//  Copyright © 2020 Dan Crosby. All rights reserved.
//

#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_NEW_ROUND_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_NEW_ROUND_ACTION_HPP

#include <utility>

#include "src/main/cpp/net/eagle0/shardok/library/GameStateW.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/action_factories/FireOutActionFactory.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/action_factories/FireSpreadActionFactory.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/action_factories/IceAndSnowAdjustmentActionFactory.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/action_factories/UndeadChangeActionFactory.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
#include "src/main/flatbuffer/net/eagle0/shardok/storage/hex_map.hpp"
#include "src/main/protobuf/net/eagle0/shardok/common/weather.pb.h"

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

// Returns the wind-speed multiplier configured in settings for the given
// weather conditions. Exposed for unit tests.
[[nodiscard]] auto WindSpeedMultiplierForConditions(
        net::eagle0::shardok::common::Weather::Conditions conditions,
        const SettingsGetter& settings) -> double;

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

    const GameStateW startingGameState;
    const SettingsGetter settings;
    const std::shared_ptr<FireOutActionFactory> fireOutActionFactory;
    const std::shared_ptr<FireSpreadActionFactory> fireSpreadActionFactory;
    const std::shared_ptr<IceAndSnowAdjustmentActionFactory> iceAdjustmentActionFactory;
    const std::shared_ptr<UndeadChangeActionFactory> undeadGrewActionFactory;

public:
    NewRoundAction(
            GameStateW gameState,
            const SettingsGetter& settingsGetter,
            const std::shared_ptr<FireOutActionFactory>& fireOutFact = nullptr,
            const std::shared_ptr<FireSpreadActionFactory>& fireSpreadFact = nullptr,
            const std::shared_ptr<IceAndSnowAdjustmentActionFactory>& iceAdjustFact = nullptr,
            const std::shared_ptr<UndeadChangeActionFactory>& undeadGrewActionFactory = nullptr);
};
}  // namespace shardok

#endif /* NEW_ROUND_ACTION_HPP */
