mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
配置表访问接口化,简化常量访问
This commit is contained in:
@@ -16,40 +16,40 @@ func (g *GameManager) AddUserPlayerExp(userId uint32, expCount uint32) {
|
||||
return
|
||||
}
|
||||
// 玩家增加冒险阅历
|
||||
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP] += expCount
|
||||
player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP] += expCount
|
||||
// 玩家升级
|
||||
for {
|
||||
playerLevel := player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]
|
||||
playerLevel := player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]
|
||||
// 读取玩家等级配置表
|
||||
playerLevelConfig, ok := gdconf.CONF.PlayerLevelDataMap[int32(playerLevel)]
|
||||
if !ok {
|
||||
playerLevelConfig := gdconf.GetPlayerLevelDataById(int32(playerLevel))
|
||||
if playerLevelConfig == nil {
|
||||
// 获取不到代表已经到达最大等级
|
||||
break
|
||||
}
|
||||
// 玩家冒险阅历不足则跳出循环
|
||||
if player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP] < uint32(playerLevelConfig.Exp) {
|
||||
if player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP] < uint32(playerLevelConfig.Exp) {
|
||||
break
|
||||
}
|
||||
// 玩家增加冒险等阶
|
||||
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]++
|
||||
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP] -= uint32(playerLevelConfig.Exp)
|
||||
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.PlayerPropertyConst.PROP_PLAYER_LEVEL)] = &proto.PropValue{
|
||||
Type: uint32(constant.PlayerPropertyConst.PROP_PLAYER_LEVEL),
|
||||
Val: int64(player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]),
|
||||
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.PlayerPropertyConst.PROP_PLAYER_LEVEL]),
|
||||
Ival: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]),
|
||||
},
|
||||
}
|
||||
playerPropNotify.PropMap[uint32(constant.PlayerPropertyConst.PROP_PLAYER_EXP)] = &proto.PropValue{
|
||||
Type: uint32(constant.PlayerPropertyConst.PROP_PLAYER_EXP),
|
||||
Val: int64(player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP]),
|
||||
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.PlayerPropertyConst.PROP_PLAYER_EXP]),
|
||||
Ival: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP]),
|
||||
},
|
||||
}
|
||||
g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, playerPropNotify)
|
||||
|
||||
Reference in New Issue
Block a user