Exemplo n.º 1
0
        public static bool getTasklistFromTxt(string taskPath, ref List <TaskObj> lst)
        {
            if (string.IsNullOrEmpty(taskPath) || !File.Exists(taskPath))
            {
                return(false);
            }

            if (lst == null)
            {
                lst = new List <TaskObj>();
            }
            else
            {
                lst.Clear();
            }

            string[] strlst = File.ReadAllLines(taskPath);
            for (int i = 0; i < strlst.Length; i++)
            {
                TaskObj task = ConvertStr2Task(strlst[i]);
                lst.Add(task);
            }

            return(true);
        }
Exemplo n.º 2
0
        public static TaskObj ConvertStr2Task(string str)
        {
            string[] lst = str.Split('-');
            if (lst.Length < 3)
            {
                return(null);
            }

            string[] lst2      = lst[2].Split(',');
            string   targetstr = "";

            if (lst2.Length <= 2)
            {
                targetstr = lst2[1];
                TaskObj task = new TaskObj(lst[0], lst[1], lst2[0], targetstr);
                return(task);
            }
            else if (lst2.Length == 3)
            {
                targetstr = lst2[1];
                TaskObj task = new TaskObj(lst[0], lst[1], lst2[0], lst2[1], Int32.Parse(lst2[2]));
                return(task);
            }
            return(null);
        }
Exemplo n.º 3
0
 public static TaskObj getCurTask(Task task)
 {
     if (task.taskName.Contains("安居乐业"))
     {
         TaskObj curTask = new TaskObj(task.taskName, task.introLong, "building@upgradeBuilding", "buildingId", task.areaId);
         return(curTask);
     }
     else if (task.taskName.Contains("经济发展"))
     {
     }
     return(null);
 }
Exemplo n.º 4
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);
        }