Exemplo n.º 1
0
    /// <summary>
    /// 引导任务请求
    /// </summary>
    public void ReqGuide(MsgPack pack)
    {
        ReqGuide reqGuide = pack.msg.reqGuide;

        GameMsg msg = new GameMsg
        {
            cmd = (int)CMD.RspGuide,
        };

        PlayerData   pd  = cacheSvc.GetPlayerDataBySession(pack.session);
        AutoGuideCfg agc = cfgSvc.GetGuideCfgData(pd.guideId);

        //校验
        if (pd.guideId == reqGuide.guideId)
        {
            //检查为智者点播任务
            if (pd.guideId == 1001)
            {
                TaskSys.Instance.CalcTaskPrgs(pd, 1);
            }

            //更新玩家数据
            pd.guideId++;
            pd.coin += agc.coin;
            PECommon.CalExp(pd, agc.exp);

            if (!cacheSvc.UpdataPlayerData(pd.id, pd))
            {
                //如果数据库更新出错
                msg.err = (int)ErrorCode.UpdateDBError;
            }
            else
            {
                RspGuide rspGuide = new RspGuide
                {
                    guideId = pd.guideId,
                    coin    = pd.guideId,
                    lv      = pd.lv,
                    exp     = pd.exp,
                };
                msg.rspGuide = rspGuide;
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ServerDataError;
        }

        pack.session.SendMsg(msg);
    }
Exemplo n.º 2
0
    public void ReqTaskReward(MsgPack msgPack)
    {
        ReqTaskReward data = msgPack.msg.reqTaskReward;
        GameMsg       msg  = new GameMsg()
        {
            cmd = (int)CMD.RspTaskReward
        };


        PlayerData pd = cacheSvc.GetPlayerDataBySession(msgPack.session);
        //获得任务模板
        TaskRewardCfg trc = cfgSvc.GetTaskRewardCfgData(data.taskId);
        //获得玩家当前任务信息
        TaskRewardData trd = CalcTaskRewardData(pd, data.taskId);

        if ((trd.prgs == trc.count) && (!trd.taked))
        {
            //任务进度完成,且奖励未被领取
            pd.coin += trc.coin;
            PECommon.CalExp(pd, trc.exp);
            trd.taked = true;
            CalcUpdatePlayerTaskArr(pd, trd);

            if (!cacheSvc.UpdataPlayerData(pd.id, pd))
            {
                //数据库写入失败
                msg.err = (int)ErrorCode.UpdateDBError;
            }
            else
            {
                msg.rspTaskReward = new RspTaskReward
                {
                    coin    = pd.coin,
                    exp     = pd.exp,
                    lv      = pd.lv,
                    taskArr = pd.taskArr
                };
            }
        }
        else
        {
            //客户端数据异常
            msg.err = (int)ErrorCode.ClientDataError;
        }

        msgPack.session.SendMsg(msg);
    }