예제 #1
0
    public void ReqFBFight(MsgPack pack)
    {
        ReqFBFight data = (ReqFBFight)pack.msg;

        SCPacketBase msg   = new RspFBFight();
        PlayerData   pd    = cacheSvc.GetPlayerDataBySession(pack.session);
        int          power = cfgSvc.GetMapCfg(data.Fbid).power;

        if (pd.Fuben < data.Fbid)
        {
            msg.error = (int)ErrorCode.ClientDataError;
        }
        else if (pd.Power < power)
        {
            msg.error = (int)ErrorCode.LackPower;
        }
        else
        {
            pd.Power -= power;
            if (cacheSvc.UpdatePlayerData(pd.Id, pd))
            {
                RspFBFight rspFBFight = new RspFBFight {
                    Fbid  = data.Fbid,
                    Power = pd.Power
                };
                msg = rspFBFight;
            }
            else
            {
                msg.error = (int)ErrorCode.UpdateDBError;
            }
        }
        pack.session.SendMsg(msg);
    }
예제 #2
0
    public void ReqFBFight(MsgPack pack)
    {
        ReqFBFight data = pack.msg.reqFBFight;

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

        PlayerData playerData = cacheSvc.GetPlayerDataBySession(pack.session);
        int        power      = cfgSvc.GetMapCfg(data.fbId).power;

        // 判断发过来的副本id是否合法
        if (data.fbId > playerData.fuben)
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }
        else if (playerData.power < power)
        {
            msg.err = (int)ErrorCode.LackPower;
        }
        else
        {
            playerData.power -= power;
            if (cacheSvc.UpdatePlayerData(playerData.id, playerData) == false)
            {
                msg.err = (int)ErrorCode.UpdateDBError;
            }
            else
            {
                RspFBFight rspFBFight = new RspFBFight {
                    fbId  = data.fbId,
                    power = playerData.power
                };

                msg.rspFBFight = rspFBFight;
            }
        }

        pack.session.SendMsg(msg);
    }
예제 #3
0
    public void ReqFBFight(PackMsg pack)
    {
        ReqFBFight    data    = pack.msg.reqFBFight;
        ServerSession session = pack.session;

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

        PlayerData playerData = cacheSvc.GetPlayerDataCache(session);
        MapCfg     mapCfg     = cfgSvc.GetMapCfg(data.fbid);

        if (playerData.fuben < data.fbid)
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }
        else if (playerData.stamina < mapCfg.costStamina)
        {
            msg.err = (int)ErrorCode.LackStamia;
        }
        else
        {
            playerData.stamina -= mapCfg.costStamina;
            if (!cacheSvc.UpdatePlayerData(playerData.id, playerData))
            {
                msg.err = (int)ErrorCode.UpdateDBError;
            }
            else
            {
                RspFBFight rspFBFight = new RspFBFight
                {
                    fbid    = data.fbid,
                    stamina = playerData.stamina,
                };
                msg.rspFBFight = rspFBFight;
            }
        }
        session.SendMsg(msg);
    }
예제 #4
0
    public void ReqDungeonFight(MsgPack pack)
    {
        ReqDungeonFight data = pack.msg.reqDungeonFight;

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

        PlayerData pd    = cacheSvc.GetPlayerDataBySession(pack.session);
        int        power = cfgSvc.GetMapCfg(data.dungeonId).power;

        if (pd.dungeon < data.dungeonId)   // 关卡进度是否合法
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }
        else if (pd.power < power)
        {
            msg.err = (int)ErrorCode.LackPower;
        }
        else
        {
            pd.power -= power;
            if (cacheSvc.UpdatePlayerData(pd.id, pd))
            {
                RspDungeonFight rspDungeonFight = new RspDungeonFight {
                    dungeonId = data.dungeonId,
                    power     = pd.power
                };
                msg.rspDungeonFight = rspDungeonFight;
            }
            else
            {
                msg.err = (int)ErrorCode.UpdateDBError;
            }
        }
        pack.session.SendMsg(msg);
    }
예제 #5
0
    public void ReqFBFight(MsgPack pack)
    {
        ReqFBFight data = pack.msg.reqFBFight;

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

        PlayerData pd    = cacheSvc.GetPlayerDataBySession(pack.session);
        int        power = cfgSvc.GetMapCfg(data.fbid).power;

        if (pd.fuben < data.fbid)
        {
            msg.err = (int)ErrorCode.ClientDataError;
        }
        else if (pd.power < power)
        {
            msg.err = (int)ErrorCode.LackPower;
        }
        else
        {
            pd.power -= power;
            if (cacheSvc.UpdatePlayerData(pd.id, pd))
            {
                msg.rspFBFight = new RspFBFight {
                    fbid  = data.fbid,
                    power = pd.power,
                };
            }
            else
            {
                msg.err = (int)ErrorCode.UpdateDBError;
            }
        }
        pack.session.SendMsg(msg);
    }