Exemple #1
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);
        }
Exemple #2
0
        public ExcuteState getPlayerInfo(webRole role)
        {
            ExcuteState state = new ExcuteState();

            try
            {
                string URL      = GlobalVal.ServerURL + "/root/gateway.action";
                string postdata = "command=player%40getPlayerInfo&version=11%2E01%2E17%2E1&token=1&info=3391&playerId=" + role.playerId;

                string outputstr = m_client.Post_retbyte2(URL, string.Empty, postdata);
                ConsoleLog.Instance.writeInformationLog(outputstr);

                string        jsontest   = Regex.Match(outputstr, "player\":(?<value>.*?)\\},").Groups["value"].Value + "}";
                webDetailRole detailinfo = (webDetailRole)JsonManager.JsonToObject(jsontest, typeof(webDetailRole));
                m_roledetail = detailinfo;

                jsontest = TestApp.fire.Tool.PickupDataStr(outputstr);;
                webCurTask taskInfo = (webCurTask)JsonManager.JsonToObject(jsontest, typeof(webCurTask));
                if (taskInfo.curTask.tasks != null && taskInfo.curTask.tasks.Count() > 0)
                {
                    m_curTask = taskInfo.curTask.tasks[0];
                    // 把信息写入配置文件
                    TaskObj task = TaskObj.getCurTask(m_curTask);
                    // 把任务写入txt
                    // 再获取一次角色列表
                    if (!string.IsNullOrEmpty(TasktxtPath) && File.Exists(TasktxtPath) && task != null)
                    {
                        List <TaskObj> tasklst = null;
                        TaskObj.getTasklistFromTxt(TasktxtPath, ref tasklst);
                        // 搜索列表
                        TaskObj tobj = tasklst.Find(delegate(TaskObj user){ return(user.TaskName == task.TaskName); });
                        if (tobj == null)
                        {//写入文档
                            TaskObj.WriteData2File(TasktxtPath, task.Obj2String());
                        }
                    }
                }
                state.State = IdentityCode.Success;
            }
            catch (Exception ex)
            {
                state.Description = "发生异常=" + ex.Message + ";\r\n" + ex.StackTrace;
                return(state);
            }
            return(state);
        }