Esempio n. 1
0
 public void ParseGameServerData(Dictionary <string, object> dic, bool overIconShow = false)
 {
     if (dic.ContainsKey("rndId"))
     {
         RoomId = dic["rndId"].ToString();
     }
     if (dic.ContainsKey("name"))
     {
         GameName = (string)dic["name"];
     }
     if (dic.ContainsKey("round"))
     {
         GameRound = dic["round"].ToString();
     }
     if (dic.ContainsKey("capacity"))
     {
         UserNum = Convert.ToInt32(dic["capacity"]);
     }
     if (dic.ContainsKey("info"))
     {
         InfoStr = (string)dic["info"];
     }
     if (dic.ContainsKey("id"))
     {
         GameRoomId = dic["id"].ToString();
     }
     if (dic.ContainsKey("status"))
     {
         status = Convert.ToInt32(dic["status"]);
     }
     if (dic.ContainsKey("gamekey"))
     {
         GameKey = (string)dic["gamekey"];
     }
     ConvertData(dic);
     if (dic.ContainsKey("users"))
     {
         List <object> usersObj = (List <object>)dic["users"];
         UserInfos = new TeaUserInfo[usersObj.Count];
         for (int i = 0; i < UserInfos.Length; i++)
         {
             UserInfos[i] = new TeaUserInfo();
         }
         for (int i = 0; i < usersObj.Count; i++)
         {
             UserInfos[i].UserName = usersObj[i].ToString();
         }
     }
     if (dic.ContainsKey("avatars"))
     {
         List <object> usersObj = (List <object>)dic["avatars"];
         for (int i = 0; i < usersObj.Count; i++)
         {
             UserInfos[i].Avatar = usersObj[i].ToString();
         }
     }
 }
Esempio n. 2
0
        public void ParseGameServerData(Dictionary <string, object> dic, bool overIconShow = false)
        {
            if (dic.ContainsKey("rndId"))
            {
                RoomId = dic["rndId"].ToString();
            }

            if (dic.ContainsKey("-ante"))
            {
                AnteInfo = string.Format("{0}{1}{2}", ",", "底分:", YxUtiles.GetShowNumber(int.Parse(dic["-ante"].ToString())));
            }

            var limiteGold = 0;

            if (dic.ContainsKey("-limiteGold"))
            {
                limiteGold = int.Parse(dic["-limiteGold"].ToString());
            }

            var gUpLimite = 0;

            if (dic.ContainsKey("-gUpLimit"))
            {
                gUpLimite = int.Parse(dic["-gUpLimit"].ToString());
            }

            var maxLimit = Math.Max(limiteGold, gUpLimite);

            LimitGold = maxLimit == 0 ? ",无限制" : string.Format("{0}{1}{2}", ",", YxUtiles.GetShowNumber(maxLimit), "准");

            if (dic.ContainsKey("name"))
            {
                GameName = (string)dic["name"];
            }
            string round = "";

            if (dic.ContainsKey("round"))
            {
                round = dic["round"].ToString();
            }
            string cRound = "";

            if (dic.ContainsKey("cround"))
            {
                cRound = dic["cround"].ToString();
            }
            GameRound = !string.IsNullOrEmpty(cRound) ? string.Format("{0}/{1}", cRound, round) : round;
            if (dic.ContainsKey("capacity"))
            {
                UserNum = Convert.ToInt32(dic["capacity"]);
            }
            if (dic.ContainsKey("info"))
            {
                InfoStr = (string)dic["info"];
            }
            if (dic.ContainsKey("id"))
            {
                GameRoomId = dic["id"].ToString();
            }
            if (dic.ContainsKey("status"))
            {
                Status = Convert.ToInt32(dic["status"]);
            }
            if (dic.ContainsKey("gamekey"))
            {
                GameKey = (string)dic["gamekey"];
            }
            ConvertData(dic);
            if (dic.ContainsKey("users"))
            {
                List <object> usersObj = (List <object>)dic["users"];
                UserInfos = new TeaUserInfo[usersObj.Count];
                for (int i = 0; i < UserInfos.Length; i++)
                {
                    UserInfos[i] = new TeaUserInfo();
                }
                for (int i = 0; i < usersObj.Count; i++)
                {
                    UserInfos[i].UserName = usersObj[i].ToString();
                }
            }
            if (dic.ContainsKey("avatars"))
            {
                List <object> usersObj = (List <object>)dic["avatars"];
                for (int i = 0; i < usersObj.Count; i++)
                {
                    UserInfos[i].Avatar = usersObj[i].ToString();
                }
            }
        }
Esempio n. 3
0
        public void ParseData(Dictionary <string, object> dic, bool overIconShow = false)
        {
            if (dic.ContainsKey("room_id"))
            {
                RoomId = (string)dic["room_id"];
            }
            if (dic.ContainsKey("game_name"))
            {
                GameName = (string)dic["game_name"];
            }
            string roundNum = "";

            if (dic.ContainsKey("round_num"))
            {
                roundNum = (string)dic["round_num"];
            }
            string roundRnum = "";

            if (dic.ContainsKey("round_rnum"))
            {
                roundRnum = (string)dic["round_rnum"];
            }
            GameRound = !string.IsNullOrEmpty(roundRnum) ? string.Format("{0}/{1}", roundRnum, roundNum) : roundNum;
            if (dic.ContainsKey("use_num"))
            {
                UseNum = (string)dic["use_num"];
            }
            if (dic.ContainsKey("info_str"))
            {
                InfoStr = (string)dic["info_str"];
            }
            if (dic.ContainsKey("create_dt"))
            {
                CreateDt = (string)dic["create_dt"];
            }
            if (dic.ContainsKey("update_dt"))
            {
                UpdateDt = (string)dic["update_dt"];
            }
            ConvertData(dic);
            dic.TryGetValueWitheKey(out UserNum, KeyUserNum);
            if (dic.ContainsKey("userinfo"))
            {
                Dictionary <string, object> userDic = (Dictionary <string, object>)dic["userinfo"];
                int index = 0;
                UserInfos = new TeaUserInfo[userDic.Count];
                for (int i = 0; i < UserInfos.Length; i++)
                {
                    UserInfos[i] = new TeaUserInfo();
                }
                foreach (KeyValuePair <string, object> userInfo in userDic)
                {
                    Dictionary <string, object> user = (Dictionary <string, object>)userInfo.Value;
                    if (user.ContainsKey("name"))
                    {
                        UserInfos[index].UserName = (string)user["name"];
                    }
                    if (user.ContainsKey("avatar"))
                    {
                        UserInfos[index].Avatar = (string)user["avatar"];
                    }
                    if (user.ContainsKey("gold"))
                    {
                        var goldObj = user["gold"];
                        UserInfos[index].Gold = goldObj.ToString();
                    }
                    UserInfos[index].Id = userInfo.Key;
                    index++;
                }
                if (UserNum == 0)
                {
                    UserNum = index;
                }
            }
            OverIcon = overIconShow;
        }