//
// Created by Dan Crosby on 11/3/21.
//

#ifndef EAGLE0_GAMESTATEHELPERS_HPP
#define EAGLE0_GAMESTATEHELPERS_HPP

#include <flatbuffers/flatbuffers.h>

#include <vector>

#include "src/main/cpp/net/eagle0/shardok/library/GameStateW.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCTypes.h"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
#include "src/main/flatbuffer/net/eagle0/shardok/storage/unit.hpp"
#include "src/main/protobuf/net/eagle0/shardok/common/game_status.pb.h"
#include "src/main/protobuf/net/eagle0/shardok/common/hex_map.pb.h"
#include "src/main/protobuf/net/eagle0/shardok/common/player_info.pb.h"

namespace shardok::fb {

using std::vector;
using HexMapProto = net::eagle0::shardok::common::HexMap;
using PlayerInfoProto = net::eagle0::shardok::common::PlayerInfo;
using net::eagle0::shardok::storage::fb::GameState;
using net::eagle0::shardok::storage::fb::GameStatus;
using net::eagle0::shardok::storage::fb::PlayerInfo;
using net::eagle0::shardok::storage::fb::Unit;
using Weather = net::eagle0::shardok::storage::fb::Weather;
using GameStatusProto = net::eagle0::shardok::common::GameStatus;

auto SetupInitialGameState(
        const GameId& gameId,
        const HexMapProto& hexMapProto,
        const vector<PlayerInfoProto>& playerInfoProtos,
        vector<Unit>& units,
        int month,
        bool isWinter,
        const SettingsGetter& settings) -> GameStateW;

auto FromPlayerInfoProto(
        flatbuffers::FlatBufferBuilder& fbb,
        const PlayerInfoProto& playerInfoProto)
        -> flatbuffers::Offset<net::eagle0::shardok::storage::fb::PlayerInfo>;

auto ToPlayerInfoProto(const PlayerInfo* fbPI) -> PlayerInfoProto;
auto ToWeatherProto(const Weather* fbW) -> net::eagle0::shardok::common::Weather;
auto ToProto(const GameStatus* fbStatus) -> GameStatusProto;

}  // namespace shardok::fb

#endif  // EAGLE0_GAMESTATEHELPERS_HPP
