public void ReqFBFightEnd(PackMsg pack) { ReqFBFightEnd data = pack.msg.reqFBFightEnd; ServerSession session = pack.session; GameMsg msg = new GameMsg { cmd = (int)(CMD.RspFBFFightEnd), }; PlayerData playerData = cacheSvc.GetPlayerDataCache(session); MapCfg mapCfg = cfgSvc.GetMapCfg(data.fbid); if (data.isWin) { if (data.costTime > 0 && data.restHp > 0) { TaskSys.Instance.CalcTaskProgs(playerData, 2); PECommon.UpdateExp(playerData, mapCfg.exp); playerData.coin += mapCfg.coin; playerData.crystal += mapCfg.crystal; if (data.fbid == playerData.fuben) { playerData.fuben++; } if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { msg.err = (int)ErrorCode.UpdateDBError; } else { RspFBFightEnd rspFBFightEnd = new RspFBFightEnd { isWin = data.isWin, fbid = data.fbid, restHp = data.restHp, costTime = data.costTime, exp = playerData.exp, lv = playerData.lv, coin = playerData.coin, crystal = playerData.crystal, fuben = playerData.fuben, }; msg.rspFBFightEnd = rspFBFightEnd; } } } else { msg.err = (int)ErrorCode.UpdateDBError; } session.SendMsg(msg); }
/// <summary> /// 回应任务完成请求 /// </summary> public void ReqTask(PackMsg pack) { ReqTask data = pack.msg.reqTask; ServerSession session = pack.session; GameMsg msg = new GameMsg { cmd = (int)CMD.RspTask }; PlayerData playerData = cacheSvc.GetPlayerDataCache(pack.session); AutoGuideCfg AutoGuideCfg = cfgSvc.GetAutoGuideCfg(data.taskID); //更新任务ID if (playerData.taskid == data.taskID) { PshTaskProgs pshTaskProgs = null; //更新任务智者点拨进度 if (playerData.taskid == 1001) { pshTaskProgs = TaskSys.Instance.CalcTaskProgs(playerData, 1); } playerData.taskid++; //更新玩家数据 playerData.coin += AutoGuideCfg.coin; PECommon.UpdateExp(playerData, AutoGuideCfg.exp); if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { msg.err = (int)ErrorCode.UpdateDBError; } else { RspTask rspTask = new RspTask { taskID = playerData.taskid, coin = playerData.coin, exp = playerData.exp, lv = playerData.lv, hp = playerData.hp, }; //发送回客户端 msg.rspTask = rspTask; if (pshTaskProgs != null) { msg.pshTaskProgs = pshTaskProgs; } } } else { msg.err = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }
public void ReqTakeTaskReward(PackMsg pack) { ReqTakeTaskReward data = pack.msg.reqTakeTaskReward; ServerSession session = pack.session; GameMsg msg = new GameMsg { cmd = (int)CMD.RspTakeTaskReward, }; int rewardID = data.rid; PlayerData playerData = cacheSvc.GetPlayerDataCache(session); TaskRewardCfg trc = cfgSvc.GetTaskRewardCfg(rewardID); TaskRewardData trd = GetTaskRewardData(playerData, rewardID); //安全验证 if (trd.progress == trc.count && !trd.taked) { playerData.coin += trc.coin; PECommon.UpdateExp(playerData, trc.exp); trd.taked = true; //更新任务进度数据 CalcTaskArr(playerData, trd); if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { msg.err = (int)ErrorCode.UpdateDBError; } else { msg.rspTakeTaskReward = new RspTakeTaskReward { coin = playerData.coin, exp = playerData.exp, lv = playerData.lv, hp = playerData.hp, taskArr = playerData.taskArr, }; session.SendMsg(msg); } } else { msg.err = (int)ErrorCode.ClientDataError; } }