Пример #1
0
    public void ReqGuide(MsgPack pack)
    {
        ReqGuide data = pack.msg.reqGuide;
        GameMsg  msg  = new GameMsg
        {
            cmd = (int)CMD.RspGuide
        };
        PlayerData pd          = cacheSrv.GetPlayerDataBySession(pack.serverSession);
        GuideCfg   guideConfig = cfgSvc.GetGuideCfgData(pd.guideid);

        //更新引导ID
        if (pd.guideid == data.guidid)
        {
            pd.guideid += 1;
            //更新玩家数据
            pd.coin += guideConfig.coin;
            CalculateExp(pd, guideConfig.exp);
            if (!cacheSrv.UpdatePlayerData(pd.id, pd))
            {
                msg.err = (int)ErroroCode.UpdateDBError;
            }
            else
            {
                msg.rspGuide = new RspGuide
                {
                    coin    = pd.coin,
                    exp     = pd.exp,
                    lv      = pd.lv,
                    guideid = pd.guideid,
                };
            }
        }
        else//开挂了
        {
            msg.err = (int)ErroroCode.ServerDataError;
        }
        //发送数据
        pack.serverSession.SendMsg(msg);
    }