/// <summary>
    /// 处理任务完成逻辑
    /// </summary>
    public void ReqGuide(MsgPack pack)
    {
        ReqGuide data = pack.msg.reqGuide;
        GameMsg  msg  = new GameMsg
        {
            cmd = (int)CMD.RspGuide,
        };

        PlayerData pd = cacheSvc.GetPlayerDataBySettion(pack.session);

        if (pd.guideid == data.guideid)//一次安全校验,如果客户端数据和服务端对不上,直接踢下线
        {
            //是否为智者引导任务
            if (pd.guideid == 1001)
            {
                TaskSys.Instance.CalcTaskPrgs(pd, 1);
            }
            GuideTaskCfg gtc = cfgSvc.GetGuideTaskCfgData(pd.guideid);
            //缓存数据变化
            pd.guideid++;
            pd.coin += gtc.coin;
            PECommon.CaculExp(pd, gtc.exp);
            if (cacheSvc.UpdatePlayerData(pd.id, pd))
            {
                msg.rspGuide = new RspGuide
                {
                    guideid = pd.guideid,
                    coin    = pd.coin,
                    exp     = pd.exp,
                    lv      = pd.lv
                };
            }
            else
            {
                msg.err = (int)ErrorCode.UpdateDbError;
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ServerDataError;
        }
        pack.session.SendMsg(msg);
    }
Beispiel #2
0
    public void ReqTakeTaskReward(MsgPack pack)
    {
        ReqTakeTaskReward data = pack.msg.reqTakeTaskReward;
        GameMsg           msg  = new GameMsg
        {
            cmd = (int)CMD.RspTakeTaskReward,
        };
        PlayerData     pd  = cacheSvc.GetPlayerDataBySettion(pack.session);
        TaskRewardCfg  trc = cfgSvc.GetTaskRewardCfg(data.rid);
        TaskRewardData trd = CalcTaskRewardData(pd, data.rid);

        if (trd.prgs == trc.count && !trd.taked)
        {
            pd.coin += trc.coin;
            PECommon.CaculExp(pd, trc.exp);
            trd.taked = true;
            //更新任务进度数据
            CalcTaskArr(pd, trd);

            if (!cacheSvc.UpdatePlayerData(pd.id, pd))
            {
                msg.err = (int)ErrorCode.UpdateDbError;
            }
            else
            {
                RspTakeTaskReward rspTakeTaskReward = new RspTakeTaskReward
                {
                    coin    = pd.coin,
                    lv      = pd.lv,
                    exp     = pd.exp,
                    taskArr = pd.taskStrArr
                };
                msg.rspTakeTaskReward = rspTakeTaskReward;
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }
        pack.session.SendMsg(msg);
    }