using System.Text.Json; using MMOserver.Game.Channel.Maps.InstanceDungeun; namespace MMOserver.Game.Channel.Maps; // Zone 데이터 구조 public record ZoneConfigData( int ZoneId, int Row, int Col, int CenterX, int CenterZ ); // Map 데이터 구조 public record MapConfigData( int MapId, string MapType, int Rows, int Cols, int ZoneSize, List Zones ); // 한 채널의 Map정보 List public record MapFileData( List Maps ); /* * maps.json 로더 * - JSON 파싱만 담당 * - Program.cs에서 Initialize() 1회 호출 */ public static class MapLoader { private static readonly JsonSerializerOptions Options = new() { PropertyNameCaseInsensitive = true }; public static MapFileData Data { get; private set; } = null!; public static void Initialize() { string json = File.ReadAllText("maps.json"); Data = JsonSerializer.Deserialize(json, Options) ?? throw new InvalidOperationException("maps.json 파싱 실패"); } public static EnumMap ParseMapType(string mapType) { return mapType.ToUpper() switch { "ROBBY" => EnumMap.ROBBY, "DUNGEON" => EnumMap.DUNGEON, "INSTANCE" => EnumMap.INSTANCE, _ => EnumMap.NONE }; } }