using System;
using System.Text;

namespace GameData
{
    /// <summary>
    /// socket注册结果包
    /// </summary>
    public class SocketRegResult
    {
        /// <summary>
        /// 1成功!   -1玩家登录太久了，请重新登录  -2提示账号在线,询问是否要挤下玩家  -3数据异常   -4您在别处登录
        /// </summary>
        public int result;

        /// <summary>
        /// 
        /// </summary>
        public string rltStr;

        /// <summary>
        /// 玩家数据
        /// </summary>
        public playerData pldata;

        /// <summary>
        /// 
        /// </summary>
        public SocketRegResult()
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="style"></param>
        /// <returns></returns>
        public static SocketRegResult GetSocketRegResult(int style)
        {
            SocketRegResult result = new SocketRegResult();
            result.result = style;
            switch (style)
            {
                case -1:
                    result.rltStr = "登录过期，请重新登录!";
                    break;
                case -2:
                    result.rltStr = "您的账号在别处登录，是否继续!";
                    break;
                case -3:
                    result.rltStr = "登录失败,请稍后再试!";
                    break;
                case -4:
                    result.rltStr = "您在别处登录!";
                    break;
                case 1:
                    result.rltStr = "登录成功!";
                    break;
            }

            return result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("result:");
            sb.Append(result);
            sb.Append(Environment.NewLine);
            sb.Append("结果字符:");
            sb.Append(rltStr);
            sb.Append(Environment.NewLine);
            sb.Append("玩家数据:");
            sb.Append(pldata.ToString());
            return sb.ToString();
        }
    }
}