Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
flswld committed 2023-10-18 17:19:53 +08:00
commit e08e9579bd
1 file changed
+25 -21
+25 -21
View File
@@ -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)
}
/************************************************** 打包封装 **************************************************/