namespace Server
{
    public static class CastleHelper
    {
        /// <summary>
        /// 获取真实的id
        /// </summary>
        /// <param name="virtualId"></param>
        /// <returns></returns>
        public static int GetRealCastle(int virtualId)
        {
            return virtualId / 3;
        }

        /// <summary>
        /// 获取虚拟的房间Id
        /// </summary>
        /// <param name="realId"></param>
        /// <returns></returns>
        public static int GetVirtualCastle(int realId)
        {
            if (realId < 0)
            {
                return realId;
            }
            
            //开启了朋友房
            if (ServerConfigManager.Instance.GameConfig.OpenFriend > 0)
            {
                //朋友房
                if (ServerConfigManager.Instance.CastlesCnt - 1 == realId)
                {
                    return realId * 3;
                }
            }
            
            return realId * 3 + 2;
        }
    }
}