Example #1
0
    public void ReqFBFightEnd(MsgPack pack)
    {
        ReqFBFightEnd data = pack.msg.reqFBFightEnd;

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

        //校验战斗是否合法
        if (data.win)
        {
            if (data.costtime > 0 && data.resthp > 0)
            {
                //根据副本ID获取相应奖励
                MapCfg     rd = cfgSvc.GetMapCfg(data.fbid);
                PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.session);

                //任务进度数据更新
                TaskSys.Instance.CalcTaskPrgs(pd, 2);

                pd.coin    += rd.coin;
                pd.crystal += rd.crystal;
                PECommon.CalcExp(pd, rd.exp);

                if (pd.fuben == data.fbid)
                {
                    pd.fuben += 1;
                }

                if (!cacheSvc.UpdatePlayerData(pd.id, pd))
                {
                    msg.err = (int)ErrorCode.UpdateDBError;
                }
                else
                {
                    RspFBFightEnd rspFBFight = new RspFBFightEnd {
                        win      = data.win,
                        fbid     = data.fbid,
                        resthp   = data.resthp,
                        costtime = data.costtime,

                        coin    = pd.coin,
                        lv      = pd.lv,
                        exp     = pd.exp,
                        crystal = pd.crystal,
                        fuben   = pd.fuben
                    };

                    msg.rspFBFightEnd = rspFBFight;
                }
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }

        pack.session.SendMsg(msg);
    }
Example #2
0
    public void ReqGuide(MsgPack pack)
    {
        ReqGuide data = pack.msg.reqGuide;
        GameMsg  msg  = new GameMsg
        {
            cmd = (int)CMD.RspGuide
        };

        PlayerData  pd          = cacheSvc.GetPlayerDataBySession(pack.session);
        GuideCfg    gc          = cfgSvc.GetGuideCfg(data.guideid);
        PshTaskPrgs pshTaskPrgs = null;

        // 更新引导ID
        if (pd.guideid == data.guideid)
        {
            // 检查是否为智者点拨任务
            if (pd.guideid == 1001)
            {
                pshTaskPrgs = TaskSys.Instance.GetTaskPrgs(pd, 1);
            }

            pd.guideid += 1;
            // 更新玩家数据
            pd.coin += gc.coin;
            PECommon.CalcExp(pd, gc.exp);

            if (!cacheSvc.UpdatePlayerData(pd.id, pd))
            {
                msg.err = (int)ErrorCode.UpdateDBError;
            }
            else
            {
                msg.rspGuide = new RspGuide
                {
                    guideid = pd.guideid,
                    coin    = pd.coin,
                    lv      = pd.lv,
                    exp     = pd.exp
                };
                msg.pshTaskPrgs = pshTaskPrgs;
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ServerDataError;
        }
        pack.session.SendMsg(msg);
    }
Example #3
0
    public void ReqGuide(MsgPack pack)
    {
        ReqGuide data = pack.msg.reqGuide;

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

        PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.session);
        GuideCfg   gc = cfgSvc.GetGuideData(data.guideid);

        //更新引导 ID
        if (pd.guideid == data.guideid)
        {
            // 检测是否为智者点拨任务
            if (pd.guideid == 1001)
            {
                TaskSys.Instance.CalcTaskPrgs(pd, 1); // 更新任务进度
            }

            pd.guideid += 1; // 此处直接 +1 就行了,但如果是连环任务,可以在后面加字段然后回传回去

            //更新玩家数据
            pd.coin += gc.coin;
            PECommon.CalcExp(pd, gc.exp);

            // 更新到数据库
            if (!cacheSvc.UpdatePlayerData(pd.id, pd))
            {
                msg.err = (int)ErrorCode.UpdateDBError;
            }
            else
            {
                msg.rspGuide = new RspGuide {
                    guideid = pd.guideid,
                    coin    = pd.coin,
                    lv      = pd.lv,
                    exp     = pd.exp
                };
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ServerDataError;
        }
        pack.session.SendMsg(msg);
    }
Example #4
0
    public void ReqTakeTaskReward(MsgPack pack)
    {
        ReqTakeTaskReward data = pack.Msg.reqTakeTaskReward;

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

        PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.Session);

        TaskRewardCfg  trc = cfgSvc.GetTaskRewardCfg(data.tid);
        TaskRewardData trd = CalcTaskRewardData(pd, data.tid);


        if (trd.prgs == trc.count && !trd.taked)
        {
            pd.coin += trc.coin;
            PECommon.CalcExp(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.taskArr
                };
                msg.rspTakeTaskReward = rspTakeTaskReward;
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }

        pack.Session.SendMsg(msg);
    }
Example #5
0
    public void ReqTakeTaskReward(MsgPack pack)
    {
        ReqTakeTaskReward data = pack.msg.reqTakeTaskReward;
        GameMsg           msg  = new GameMsg
        {
            cmd = (int)CMD.RspTakeTaskReward,
        };
        PlayerData     pd    = CacheSvc.Instance.GetPlayerDataBySession(pack.session);
        TaskRewardCfg  trcfg = CfgSvc.Instance.GetTaskRewardCfg(data.rid);
        TaskRewardData trd   = GetTaskRewardData(pd, data.rid);

        if (trd.prgs == trcfg.count && !trd.taked)
        {
            pd.coin += trcfg.coin;
            PECommon.CalcExp(pd, trcfg.exp);
            trd.taked = true;
            CalcTaskArr(pd, trd);

            if (!CacheSvc.Instance.UpdatePlayerData(pd.id, pd, pack.session))
            {
                msg.err = (int)ErrorCode.UpdateDBError;
            }
            else
            {
                msg.rspTakeTaskReward = new RspTakeTaskReward
                {
                    coin    = pd.coin,
                    exp     = pd.exp,
                    lv      = pd.lv,
                    taskArr = pd.taskArr,
                };
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }
        pack.session.SendMsg(msg);
    }
Example #6
0
    public void ReqFBFightEnd(MsgPack pack)
    {
        ReqFBFightEnd data = pack.msg.reqFBFightEnd;
        GameMsg       msg  = new GameMsg
        {
            cmd = (int)CMD.RspFBFightEnd,
        };

        //校验战斗结果是否合法
        if (data.iswin)
        {
            if (data.costtime > 10 && data.resthp > 0)
            {
                //根据副本ID获取奖励数据
                MapCfg     mapcfg = CfgSvc.Instance.GetMapCfg(data.fbid);
                PlayerData pd     = CacheSvc.Instance.GetPlayerDataBySession(pack.session);

                pd.coin    += mapcfg.coin;
                pd.crystal += mapcfg.crystal;
                PECommon.CalcExp(pd, mapcfg.exp);

                if (pd.mission == data.fbid)
                {
                    pd.mission++;
                }

                if (!CacheSvc.Instance.UpdatePlayerData(pd.id, pd, pack.session))
                {
                    msg.err = (int)ErrorCode.UpdateDBError;
                }
                else
                {
                    RspFBFightEnd rspFBFightEnd = new RspFBFightEnd
                    {
                        iswin    = data.iswin,
                        fbid     = data.fbid,
                        resthp   = data.resthp,
                        costtime = data.costtime,

                        coin    = pd.coin,
                        lv      = pd.lv,
                        exp     = pd.exp,
                        crystal = pd.crystal,
                        fuben   = pd.mission,
                    };

                    msg.rspFBFightEnd = rspFBFightEnd;
                    //更新任务进度数据
                    TaskSys.Instance.CalcTaskPrgs(pd, 2);
                }
            }
            else
            {
                msg.err = (int)ErrorCode.ClientDataError;
            }
        }
        else
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }

        pack.session.SendMsg(msg);
    }