From 114aa1399c2240086a705ab4389f044f64aa721c Mon Sep 17 00:00:00 2001 From: UnKownOwO <80520429@qq.com> Date: Wed, 18 Oct 2023 16:23:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A7=92=E8=89=B2=E7=AD=89?= =?UTF-8?q?=E7=BA=A7=E8=B6=85=E8=BF=87=E9=85=8D=E7=BD=AE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gs/game/player_base.go | 46 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/gs/game/player_base.go b/gs/game/player_base.go index ca664eee..5cd592b8 100644 --- a/gs/game/player_base.go +++ b/gs/game/player_base.go @@ -1,13 +1,13 @@ package game import ( + "hk4e/protocol/cmd" "time" "hk4e/common/constant" "hk4e/gdconf" "hk4e/gs/model" "hk4e/pkg/logger" - "hk4e/protocol/cmd" "hk4e/protocol/proto" ) @@ -31,6 +31,11 @@ func (g *Game) HandlePlayerExpAdd(userId uint32) { // 获取不到代表已经到达最大等级 break } + // 确保拥有下一级的配置表 + if gdconf.GetPlayerLevelDataByLevel(int32(playerLevel+1)) == nil { + // 获取不到代表已经到达最大等级 + break + } // 玩家冒险阅历不足则跳出循环 if player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP] < uint32(playerLevelConfig.Exp) { break @@ -38,27 +43,26 @@ func (g *Game) HandlePlayerExpAdd(userId uint32) { // 玩家增加冒险等阶 player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]++ player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP] -= uint32(playerLevelConfig.Exp) - - // 更新玩家属性 - playerPropNotify := &proto.PlayerPropNotify{ - PropMap: make(map[uint32]*proto.PropValue), - } - playerPropNotify.PropMap[uint32(constant.PLAYER_PROP_PLAYER_LEVEL)] = &proto.PropValue{ - Type: uint32(constant.PLAYER_PROP_PLAYER_LEVEL), - Val: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]), - Value: &proto.PropValue_Ival{ - Ival: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]), - }, - } - playerPropNotify.PropMap[uint32(constant.PLAYER_PROP_PLAYER_EXP)] = &proto.PropValue{ - Type: uint32(constant.PLAYER_PROP_PLAYER_EXP), - Val: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP]), - Value: &proto.PropValue_Ival{ - Ival: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP]), - }, - } - g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, playerPropNotify) } + // 更新玩家属性 + playerPropNotify := &proto.PlayerPropNotify{ + PropMap: make(map[uint32]*proto.PropValue), + } + playerPropNotify.PropMap[uint32(constant.PLAYER_PROP_PLAYER_LEVEL)] = &proto.PropValue{ + Type: uint32(constant.PLAYER_PROP_PLAYER_LEVEL), + Val: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]), + Value: &proto.PropValue_Ival{ + Ival: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]), + }, + } + playerPropNotify.PropMap[uint32(constant.PLAYER_PROP_PLAYER_EXP)] = &proto.PropValue{ + Type: uint32(constant.PLAYER_PROP_PLAYER_EXP), + Val: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP]), + Value: &proto.PropValue_Ival{ + Ival: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP]), + }, + } + g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, playerPropNotify) } /************************************************** 打包封装 **************************************************/