예제 #1
0
        public static string GetForceInfo(HttpClient2 client)
        {
            string outputstr            = client.DownloadBytearr2(GlobalVal.ServerURL + "/root/gateway.action?command=player@getForceInfo", string.Empty, false);
            webAction_createrole action = (webAction_createrole)JsonManager.JsonToObject(outputstr, typeof(webAction_createrole));

            Reward jiangli = action.action.data.reward;

            /*魏:1 蜀:2 吴:3*/
            outputstr = client.Post_retbyte2(GlobalVal.ServerURL + "/root/gateway.action?command=player@setPlayerForce",
                                             string.Empty, "forceId=" + jiangli.forceId);

            Console.WriteLine(outputstr);

            return(outputstr);
        }
예제 #2
0
        public ExcuteState getPlayerList()
        {
            ExcuteState state = new ExcuteState();

            try
            {
                string jsontext = null;
                //byte[] arrOutput = m_client.DownloadBytearr(GlobalVal.CmdURL + "player@getPlayerList", string.Empty, false);
                //byte[] arrDescrypt = ZlibCompress.DecompressBytes(arrOutput);
                while (true)
                {
                    string outputstr = m_client.DownloadBytearr2(GlobalVal.CmdURL + "player@getPlayerList", string.Empty, false);

                    jsontext = Regex.Match(outputstr, "\\[(?<value>.*?)\\]").Groups["value"].Value;

                    if (string.IsNullOrEmpty(jsontext))
                    {// 创角
                        RoleCreate.GetForceInfo(m_client);
                    }
                    else
                    {
                        break;
                    }
                }

                // 目前只有一个角色
                webRole webrole = (webRole)JsonManager.JsonToObject(jsontext, typeof(webRole));
                if (webrole != null)
                {
                    Rolelist.Add(webrole);
                }
                else
                {
                    state.Description = "getPlayerList() 转化json为对象失败, json=" + jsontext;
                    return(state);
                }

                state.State = IdentityCode.Success;
            }
            catch (Exception ex)
            {
                state.Description = "发生异常=" + ex.Message + ";\r\n" + ex.StackTrace;
                return(state);
            }
            return(state);
        }