//
// AI Battle Simulator Configuration Loader
//

#ifndef EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_CONFIG_HPP
#define EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_CONFIG_HPP

#include <memory>
#include <string>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
#include "src/main/protobuf/net/eagle0/shardok/ai_battle_simulator/ai_battle_config.pb.h"
#pragma clang diagnostic pop

namespace shardok::ai_battle_simulator {

using BattleConfigProto = net::eagle0::shardok::ai_battle_simulator::BattleConfig;

class AiBattleConfigLoader {
public:
    // Load battle configuration from a JSON file
    // Returns nullptr if loading fails
    [[nodiscard]] static std::unique_ptr<BattleConfigProto> LoadFromJsonFile(
            const std::string& filepath);

    // Load battle configuration from a JSON string
    // Returns nullptr if parsing fails
    [[nodiscard]] static std::unique_ptr<BattleConfigProto> LoadFromJsonString(
            const std::string& jsonString);

    // Generate a default "Perf" configuration matching Unity's Custom Battle Perf setup
    // - 6 units per side (Heavy Infantry, professions 1-6)
    // - Map: Alah
    // - Month: configurable (default 4 = April)
    // - Both players use Iterative Deepening AI
    [[nodiscard]] static std::unique_ptr<BattleConfigProto> CreateDefaultPerfConfig(int month = 4);

    // Convert battle configuration to JSON string for saving/debugging
    [[nodiscard]] static std::string ToJsonString(const BattleConfigProto& config);
};

}  // namespace shardok::ai_battle_simulator

#endif  // EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_CONFIG_HPP
