예제 #1
0
        public ASObject Execute(Int64 userid, ASObject data)
        {
            var session = Variable.OnlinePlayer[userid] as TGGSession;

            if (session == null)
            {
                return(CommonHelper.ErrorResult((int)ResultType.FAIL));
            }
#if DEBUG
            XTrace.WriteLine("{0}家臣任务购买--{1}", session.Player.User.player_name, "TASK_BUY");
#endif
            var user       = session.Player.User.CloneEntity();
            var userextend = session.Player.UserExtend.CloneEntity();

            if (!CheckMoney(user, userextend.task_role_refresh, session)) //金钱验证
            {
                return(BuildData(userextend.task_role_refresh == 0 ? (int)ResultType.BASE_PLAYER_COIN_ERROR : (int)ResultType.BASE_PLAYER_GOLD_ERROR, null, 0));
            }
            var newtasks = new Share.TGTask().RandomTask(session.Player.User.id);
            if (!newtasks.Any())
            {
                return(BuildData((int)ResultType.APPRAISE_REFLASH_WRONG, null, 0));
            }
            var list = new EntityList <tg_task>();
            list.AddRange(newtasks);
            list.Insert();
#if DEBUG
            XTrace.WriteLine("购买的任务数{0}", newtasks.Count);
#endif
            //更新用户和用户扩展
            userextend.task_role_refresh++;
            userextend.Update();
            session.Player.UserExtend = userextend;
            return(BuildData((int)ResultType.SUCCESS, newtasks, 2 - userextend.task_role_refresh));
        }
예제 #2
0
        /// <summary>
        /// 任务步骤更新验证
        /// </summary>
        /// <param name="task">tg_task实体</param>
        /// <param name="basestep">基表任务条件</param>
        /// <param name="npc">前端提交npcid</param>
        /// <returns>验证后返回的数据</returns>
        private ASObject FinishTaskCheck(tg_task task, string basestep, int npc)
        {
            var tuple = new Share.TGTask().CheckTaskStep(basestep, task.task_step_data, task.user_id, npc);

            if (tuple.Item1 < 0)
            {
                return(new ASObject(BulidReturnData(tuple.Item1, null)));
            }
            Common.getInstance().TaskUpdate(task, tuple.Item2, basestep);
            // RemoveQuene(task.user_id);
            return(new ASObject(BulidReturnData((int)ResultType.SUCCESS, task)));
        }
예제 #3
0
        /// <summary>
        /// 任务步骤更新验证
        /// </summary>
        /// <param name="task">tg_task实体</param>
        /// <param name="basestep">基表任务条件</param>
        /// <param name="npc">前端提交npcid</param>
        /// <returns>验证后返回的数据</returns>
        private ASObject FinishTaskCheck(tg_task task, string basestep, int npc)
        {
            string step   = task.task_step_data;
            Int64  userid = task.user_id;
            var    tuple  = new Share.TGTask().CheckTaskStep(basestep, step, userid, npc);

            if (tuple.Item1 < 0)
            {
                XTrace.WriteLine("未catch,任务更新出错,错误值{0}", tuple.Item1);
                return(BulidReturnData(tuple.Item1, null));
            }

            TaskUpdate(task, tuple.Item2, basestep);

            return(BulidReturnData((int)ResultType.SUCCESS, task));
        }
예제 #4
0
        //private static TASK_VOCATION_UPDATE ObjInstance = null;

        ///// <summary> TASK_VOCATION_UPDATE单体模式 </summary>
        //public static TASK_VOCATION_UPDATE getInstance()
        //{
        //    return ObjInstance ?? (ObjInstance = new TASK_VOCATION_UPDATE());
        //}

        //  private ConcurrentDictionary<Int64, bool> dic = new ConcurrentDictionary<long, bool>();

        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            var userid = session.Player.User.id;

            // if(!CheckQueue(userid))return null;
            if (!data.ContainsKey("type") || !data.ContainsKey("taskId"))
            {
                return(null);
            }
            var type     = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "type").Value);
            var npc      = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "npcId").Value);
            var step     = data.FirstOrDefault(q => q.Key == "data").Value;
            var mainid   = Convert.ToInt64(data.FirstOrDefault(q => q.Key == "taskId").Value);
            var state    = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "state").Value);
            var taskinfo = tg_task.FindByid(mainid);

            if (taskinfo == null || taskinfo.task_type != (int)TaskType.VOCATION_TASK)
            {
                return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_NOTASK, null)));
            }
            var baseinfo = Variable.BASE_TASKVOCATION.FirstOrDefault(q => q.id == taskinfo.task_id);

            if (baseinfo == null)
            {
                return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_NOTASK, null)));
            }
            var tasktype = baseinfo.type;
            var steptype = Convert.ToInt32(baseinfo.stepCondition.Split(new[] { '|', '_' })[0]);

            if (type == 1)
            {
                if (taskinfo.task_state != (int)TaskStateType.TYPE_UNFINISHED)
                {
                    return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_NOTASK, null)));
                }
                #region 任务步骤验证与更新
                switch (steptype)
                {
                case (int)TaskStepType.BUILD:     //监督建筑
                case (int)TaskStepType.ESCORT:    //护送
                case (int)TaskStepType.CLICK:     //点击任意玩家
                case (int)TaskStepType.TYPE_DIALOG:
                {
                    var tuple = new Share.TGTask().CheckTaskStep(baseinfo.stepCondition, taskinfo.task_step_data, userid, npc);
                    if (tuple.Item1 < 0)
                    {
                        return(new ASObject(BulidData(tuple.Item1, null)));
                    }
                    Common.getInstance().TaskUpdate(taskinfo, tuple.Item2, baseinfo.stepCondition);
                }
                break;

                case (int)TaskStepType.SEND:     //从小事赚起
                    if (!CheckDiaAndSend(baseinfo.stepCondition, npc, taskinfo))
                    {
                        return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UPDATEWRONG, null)));
                    }
                    break;

                case (int)TaskStepType.FASTNPC:     //对玩家对话,有一个玩家可以快速完成
                    if (!CheckFastDialogue(baseinfo.stepCondition, npc, taskinfo))
                    {
                        return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UPDATEWRONG, null)));
                    }
                    break;

                case (int)TaskStepType.NPCCOUNTS:    //与多个npc对话,达到总次数
                    if (!CheckTwoNpc(baseinfo.stepCondition, npc, taskinfo))
                    {
                        return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UPDATEWRONG, null)));
                    }
                    break;

                case (int)TaskStepType.STAND_GUARD:    //站岗
                {
                    if (!CheckStandGuard(baseinfo.time, baseinfo.stepCondition, taskinfo, npc, session.Player.Scene.scene_id, session.Player.User.player_camp))
                    {
                        return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UPDATEWRONG, null)));
                    }
                }
                break;

                case (int)TaskStepType.ASSASSINATION:    //刺杀
                {
                    if (!Common.getInstance().KillTask(npc, baseinfo, session.Player.User.player_camp, session.Player.Role.Kind.role_level, ref taskinfo))
                    {
                        return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UPDATEWRONG, null)));
                    }
                }
                break;

                case (int)TaskStepType.FIGHTING_CONTINUOUS:    //连续战斗
                    return(Common.ObjInstance.ContinueFight(session, taskinfo, baseinfo.stepCondition, npc));

                case (int)TaskStepType.GUARD:    //守护
                {
                    if (!Common.getInstance().WatchTask(npc, baseinfo, session.Player.User.player_camp, session.Player.Role.Kind.role_level, ref taskinfo))
                    {
                        return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UPDATEWRONG, null)));
                    }
                }
                break;

                //谣言类
                case (int)TaskStepType.RUMOR:
                case (int)TaskStepType.FIRE:
                case (int)TaskStepType.BREAK:
                case (int)TaskStepType.SEll_WINE:
                {
                    return(Common.getInstance().RumorTask(session.Player, taskinfo, baseinfo.stepCondition, npc));
                }

                //戒严类
                case (int)TaskStepType.ARREST_RUMOR:
                case (int)TaskStepType.ARREST_FIRE:
                case (int)TaskStepType.ARREST_BREAK:
                case (int)TaskStepType.ARREST_SEll_WINE:
                {
                    return(Common.getInstance().ArrestTask(baseinfo.time, baseinfo.stepCondition, taskinfo, npc, session.Player.Scene.scene_id));
                }

                case (int)TaskStepType.DUOMAOMAO:
                    return(Common.getInstance().DuoMaoMaoTask(npc, state, baseinfo, taskinfo));
                }
                #endregion
                return(new ASObject(BulidData((int)ResultType.SUCCESS, taskinfo)));
            }
            if (type != 2)
            {
                return(new ASObject(BulidData((int)ResultType.FRONT_DATA_ERROR, null)));
            }
            if (taskinfo.task_state != (int)TaskStateType.TYPE_REWARD)  //验证任务是否完成
            {
                return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UNFINISH, null)));
            }
            var rewardstring = "";
            switch (steptype)
            {
            case (int)TaskStepType.FIGHTING_CONTINUOUS:
            {
                var tuple = Common.getInstance().GetContinueReward(userid, taskinfo.task_step_data, baseinfo.id);
                if (tuple.Item1 < 0)
                {
                    return(new ASObject(BulidData(tuple.Item1, null)));
                }
                rewardstring = tuple.Item2;
            }
            break;

            case (int)TaskStepType.DUOMAOMAO:
                rewardstring = Common.getInstance().GetRewardString(userid, baseinfo);
                break;

            default: rewardstring = Common.getInstance().GetRewardString(baseinfo, session); break; //领取奖励
            }
            if (rewardstring != "")                                                                 //连续战斗没有胜利没有奖励
            {
                if (!new Share.Reward().GetReward(rewardstring, userid, (int)ModuleNumber.TASK, (int)TaskCommand.TASK_VOCATION_UPDATE))
                {
                    return(new ASObject(BulidData((int)ResultType.REWARD_FALSE, null)));
                }
            }
            taskinfo.Delete();
            //大名令更新
            var damingtype = tasktype == 1 ? (int)DaMingType.评定 : (int)DaMingType.高级评定;
            new Share.DaMing().CheckDaMing(userid, damingtype);
            //评定主线任务统计
            new Share.TGTask().VocationAdd(userid, tasktype);
            ////日志记录 格式:任务_任务主键id_任务id|奖励字符串
            //var logdata = string.Format("T_{0}_{1}%{2}", taskinfo.id, taskinfo.task_id, rewardstring);
            //new Share.Log().WriteLog(userid, (int)LogType.Delete, (int)ModuleNumber.TASK, (int)TaskCommand.TASK_VOCATION_UPDATE, "任务", "身份更新", "身份", 0, 0, 0, logdata);
            return(new ASObject(BulidData((int)ResultType.SUCCESS, null)));
        }
예제 #5
0
        //private static WORK_UPDATE ObjInstance;

        ///// <summary> WORK_UPDATE单体模式 </summary>
        //public static WORK_UPDATE GetInstance()
        //{
        //    return ObjInstance ?? (ObjInstance = new WORK_UPDATE());
        //}

        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            var userid = session.Player.User.id;

            if (!data.ContainsKey("type") || !data.ContainsKey("taskId"))
            {
                return(null);
            }
            var type         = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "type").Value);
            var npc          = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "npcId").Value);
            var step         = data.FirstOrDefault(q => q.Key == "data").Value;
            var mainid       = Convert.ToInt64(data.FirstOrDefault(q => q.Key == "taskId").Value);
            var rewardstring = "";
            var WorkInfo     = tg_task.GetEntityByIdAndUserId(mainid, session.Player.User.id);// tg_task.FindByid(mainid);

            if (WorkInfo == null || WorkInfo.task_type != (int)TaskType.WORK_TASK || WorkInfo.task_state == (int)TaskStateType.TYPE_UNRECEIVED)
            {
                return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_NOTASK, null)));
            }

            var baseinfo = Variable.BASE_TASKVOCATION.FirstOrDefault(q => q.id == WorkInfo.task_id);

            if (baseinfo == null)
            {
                return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_NOTASK, null)));
            }
            var steptype = Convert.ToInt32(baseinfo.stepCondition.Split(new[] { '|', '_' })[0]);

            if (type == 1)
            {
                if (WorkInfo.task_state != (int)TaskStateType.TYPE_UNFINISHED)
                {
                    return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_NOTASK, null)));
                }
                #region 任务步骤验证与更新
                switch (steptype)
                {
                case (int)TaskStepType.STAND_GUARD:    //站岗
                {
                    if (!CheckStandGuard(baseinfo.time, baseinfo.stepCondition, WorkInfo, npc, session.Player.Scene.scene_id, session.Player.User.player_camp))
                    {
                        return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UPDATEWRONG, null)));
                    }
                }
                break;

                case (int)TaskStepType.ASSASSINATION:    //刺杀
                {
                    if (!KillTask(npc, baseinfo, session.Player.User.player_camp, session.Player.Role.Kind.role_level, ref WorkInfo))
                    {
                        return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UPDATEWRONG, null)));
                    }
                }
                break;

                case (int)TaskStepType.FIGHTING_CONTINUOUS:    //连续战斗
                {
                    return(ContinueFight(session, WorkInfo, baseinfo.stepCondition, npc));
                }

                case (int)TaskStepType.GUARD:    //守护
                {
                    var tuple = WatchTask(npc, baseinfo.time, session.Player.User.player_camp, session.Player.Role.Kind.role_level, WorkInfo);
                    if (!tuple.Item2)
                    {
                        return(new ASObject(BulidData((int)tuple.Item1, null)));
                    }
                }
                break;

                //谣言类
                case (int)TaskStepType.RUMOR:
                case (int)TaskStepType.FIRE:
                case (int)TaskStepType.BREAK:
                case (int)TaskStepType.SEll_WINE:
                {
                    return(Common.GetInstance().RumorTask(session.Player, WorkInfo, baseinfo.stepCondition, npc));
                }

                //戒严类
                case (int)TaskStepType.ARREST_RUMOR:
                case (int)TaskStepType.ARREST_FIRE:
                case (int)TaskStepType.ARREST_BREAK:
                case (int)TaskStepType.ARREST_SEll_WINE:
                {
                    return(Common.GetInstance().ArrestTask(baseinfo.time, baseinfo.stepCondition, WorkInfo, npc, session.Player.Scene.scene_id));
                }

                case (int)TaskStepType.ESCORT:    //护送
                {
                    var tuple = new Share.TGTask().CheckTaskStep(baseinfo.stepCondition, WorkInfo.task_step_data, userid, npc);
                    if (tuple.Item1 < 0)
                    {
                        return(new ASObject(BulidData(tuple.Item1, null)));
                    }
                    Common.GetInstance().TaskUpdate(WorkInfo, tuple.Item2, baseinfo.stepCondition);
                }
                break;
                }
                #endregion
                return(new ASObject(BulidData((int)ResultType.SUCCESS, WorkInfo)));
            }
            if (type != 2)
            {
                return(new ASObject(BulidData((int)ResultType.FRONT_DATA_ERROR, null)));
            }
            if (WorkInfo.task_state != (int)TaskStateType.TYPE_REWARD)  //验证任务是否完成
            {
                return(new ASObject(BulidData((int)ResultType.TASK_VOCATION_UNFINISH, null)));
            }

            switch (steptype)
            {
            case (int)TaskStepType.FIGHTING_CONTINUOUS:
            {
                var tuple = GetContinueReward(userid, WorkInfo.task_step_data, baseinfo.id);
                if (tuple.Item1 < 0)
                {
                    return(new ASObject(BulidData(tuple.Item1, null)));
                }
                rewardstring = tuple.Item2;
            } break;

            default:
            {
                var maxc   = baseinfo.workRewardMaxCon;
                var maxr   = baseinfo.workRewardMax;
                var mediac = baseinfo.rewardMediumCon;
                var mediar = baseinfo.workRewardMedium;
                var reward = baseinfo.workReward;
                rewardstring = Common.GetInstance().GetRewardString(maxc, maxr, mediac, mediar, reward, session.Player.Role);           //领取奖励
            } break;
            }
            if (rewardstring != "") //连续战斗没有胜利没有奖励
            {
                if (!new Share.Reward().GetReward(rewardstring, userid, (int)ModuleNumber.WORK, (int)WorkCommand.WORK_UPDATE))
                {
                    return(new ASObject(BulidData((int)ResultType.REWARD_FALSE, null)));
                }
            }
            new Share.DaMing().CheckDaMing(userid, (int)DaMingType.工作);
            ////格式:任务_任务主键id_任务id|奖励字符串
            //var logdata = string.Format("T_{0}_{1}%{2}", WorkInfo.id, WorkInfo.task_id, rewardstring);
            //new Share.Log().WriteLog(userid, (int)LogType.Delete, (int)ModuleNumber.WORK, (int)WorkCommand.WORK_UPDATE, "工作", "工作更新", "工作", 0, 0, 0, logdata);
            var coolingtime = WorkInfo.task_coolingtime;
            WorkInfo    = Common.GetInstance().WorkTasksInit(WorkInfo);
            WorkInfo.id = mainid;
            WorkInfo.task_coolingtime = coolingtime;
            WorkInfo.Update();
            Common.GetInstance().ClearTime(WorkInfo.user_id);
            return(new ASObject(BulidData((int)ResultType.SUCCESS, WorkInfo)));
        }
예제 #6
0
        public ASObject Execute(Int64 userid, ASObject data)
        {
            var session = Variable.OnlinePlayer[userid] as TGGSession;

            if (session == null)
            {
                return(CommonHelper.ErrorResult((int)ResultType.FAIL));
            }
#if DEBUG
            XTrace.WriteLine("{0}职业任务购买--{1}", session.Player.User.player_name, "TASK_VOCATION_BUY");
#endif
            const int result = (int)ResultType.SUCCESS;

            var type = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "type").Value);
            if (type != 1 && type != 2)
            {
                return(new Share.TGTask().BuildVoctionData((int)ResultType.FRONT_DATA_ERROR, null, 0));
            }
            var spe        = tg_task.GetSpecialVocTask(userid);
            var voc        = session.Player.User.player_vocation;
            var _identify  = session.Player.Role.Kind.role_identity;
            var user       = session.Player.User.CloneEntity();
            var userextend = session.Player.UserExtend.CloneEntity();
            var identify   = GetReflashIdentify(_identify, voc, type, userextend.task_vocation_isgo);
            if (type == 2)
            {
                if (userextend.task_vocation_isgo != 1)
                {
                    return(new Share.TGTask().BuildVoctionData((int)ResultType.TASK_VOCATION_ISRESET, null, 0));
                }
            }
            if (type == 1)
            {
                if (userextend.task_vocation_refresh < 0 || userextend.task_vocation_refresh > 1)
                {
                    return(new Share.TGTask().BuildVoctionData((int)ResultType.TASK_VOCATION_COUNTERROR, null, 0));
                }
            }
            if (!CheckIdentify(voc, identify))
            {
                return(new Share.TGTask().BuildVoctionData((int)ResultType.TASK_VOCATION_NONEW, null, 0));
            }
            ;                                                                                              //大名没有职业任务
            var newtasks = new Share.TGTask().GetNewVocationTasks(identify, userid, voc);
            if (!newtasks.Any())
            {
                return(new Share.TGTask().BuildVoctionData((int)ResultType.TASK_VOCATION_NOREFLASH, null, 0));
            }

            if (type == 1 && !CheckMoney(user, userextend.task_vocation_refresh, session))//金钱验证
            {
                return(new Share.TGTask().BuildVoctionData(userextend.task_vocation_refresh == 0 ? (int)ResultType.BASE_PLAYER_COIN_ERROR : (int)ResultType.BASE_PLAYER_GOLD_ERROR, null, 0));
            }
            tg_task.GetVocationTaskDel(userid, 0);
            tg_task.GetListInsert(newtasks);
            if (spe != null)
            {
                newtasks.AddRange(spe);
            }
            GetReflashUpdate(type, userextend, session);

            var count = (2 - userextend.task_vocation_refresh);
            return(new Share.TGTask().BuildVoctionData(result, newtasks, count));
        }