using System;
using System.Collections.Generic;
using System.IO;
using Villain.Data;

namespace Fiesta.Config
{
	public sealed class ServerInfo
	{
		public LoginServerInfo Login = new LoginServerInfo();
		public List<WorldServerInfo> Worlds = new List<WorldServerInfo>();

		public static ServerInfo Load(string path)
		{
			return JSON.Deserialize<ServerInfo>(File.ReadAllText(path));
		}

		public string Serialize()
		{
			return JSON.Serialize(this);
		}

		public class LoginServerInfo
		{
			public string Host = "";
			public LoginServerInfoPorts Ports = new LoginServerInfoPorts();

			public class LoginServerInfoPorts
			{
				public Int32 Players = 0;
				public Int32 Worlds = 0;
			}
		}

		public class WorldServerInfo
		{
			public byte ID = 0;

			public string Name = "";

			public string Host = "";
			public WorldServerInfoPorts Ports = new WorldServerInfoPorts();
			
			public List<ZoneServerInfo> Zones = new List<ZoneServerInfo>();

			public class WorldServerInfoPorts
			{
				public Int32 Players = 0;
				public Int32 Zones = 0;
			}
		}

		public class ZoneServerInfo
		{
			public byte ID = 0;

			public string Host = "";
			public ZoneServerInfoPorts Ports = new ZoneServerInfoPorts();

			public class ZoneServerInfoPorts
			{
				public Int32 Players = 0;
			}
		}
	}
}