mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 16:02:26 +08:00
武器上锁功能
This commit is contained in:
@@ -114,17 +114,17 @@ func (g *GameDataConfig) load() {
|
|||||||
g.loadSceneData() // 场景
|
g.loadSceneData() // 场景
|
||||||
g.loadScenePoint() // 场景传送点
|
g.loadScenePoint() // 场景传送点
|
||||||
g.loadSceneTagData() // 场景地图图标
|
g.loadSceneTagData() // 场景地图图标
|
||||||
g.loadScene() // 场景详情
|
// g.loadScene() // 场景详情
|
||||||
g.loadWorldAreaData() // 世界区域
|
g.loadWorldAreaData() // 世界区域
|
||||||
g.loadGatherData() // 采集物
|
g.loadGatherData() // 采集物
|
||||||
g.loadFetterData() // 角色资料解锁
|
g.loadFetterData() // 角色资料解锁
|
||||||
g.loadItemData() // 统一道具
|
g.loadItemData() // 统一道具
|
||||||
g.loadAvatarLevelData() // 角色等级
|
g.loadAvatarLevelData() // 角色等级
|
||||||
g.loadAvatarPromoteData() // 角色突破
|
g.loadAvatarPromoteData() // 角色突破
|
||||||
g.loadPlayerLevelData() // 玩家等级
|
g.loadPlayerLevelData() // 玩家等级
|
||||||
g.loadWeaponLevelData() // 武器等级
|
g.loadWeaponLevelData() // 武器等级
|
||||||
g.loadWeaponPromoteData() // 武器突破
|
g.loadWeaponPromoteData() // 武器突破
|
||||||
g.loadRewardData() // 奖励
|
g.loadRewardData() // 奖励
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameDataConfig) readCsvFileData(fileName string) []byte {
|
func (g *GameDataConfig) readCsvFileData(fileName string) []byte {
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package gdconf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"hk4e/common/constant"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"hk4e/common/constant"
|
|
||||||
"hk4e/pkg/logger"
|
"hk4e/pkg/logger"
|
||||||
|
|
||||||
"github.com/jszwec/csvutil"
|
"github.com/jszwec/csvutil"
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
|
|||||||
weaponId := g.AddUserWeapon(player.PlayerID, uint32(avatarDataConfig.InitialWeapon))
|
weaponId := g.AddUserWeapon(player.PlayerID, uint32(avatarDataConfig.InitialWeapon))
|
||||||
|
|
||||||
// 角色装上初始武器
|
// 角色装上初始武器
|
||||||
g.WearUserAvatarEquip(player.PlayerID, avatarId, weaponId)
|
g.WearUserAvatarWeapon(player.PlayerID, avatarId, weaponId)
|
||||||
|
|
||||||
g.UpdateUserAvatarFightProp(player.PlayerID, avatarId)
|
g.UpdateUserAvatarFightProp(player.PlayerID, avatarId)
|
||||||
|
|
||||||
@@ -359,87 +359,6 @@ func (g *GameManager) PacketAvatarPropNotify(avatar *model.Avatar) *proto.Avatar
|
|||||||
return avatarPropNotify
|
return avatarPropNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) WearEquipReq(player *model.Player, payloadMsg pb.Message) {
|
|
||||||
logger.Debug("user wear equip, uid: %v", player.PlayerID)
|
|
||||||
req := payloadMsg.(*proto.WearEquipReq)
|
|
||||||
avatarGuid := req.AvatarGuid
|
|
||||||
equipGuid := req.EquipGuid
|
|
||||||
avatar, ok := player.GameObjectGuidMap[avatarGuid].(*model.Avatar)
|
|
||||||
if !ok {
|
|
||||||
logger.Error("avatar error, avatarGuid: %v", avatarGuid)
|
|
||||||
g.SendError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
weapon, ok := player.GameObjectGuidMap[equipGuid].(*model.Weapon)
|
|
||||||
if !ok {
|
|
||||||
logger.Error("equip error, equipGuid: %v", equipGuid)
|
|
||||||
g.SendError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
g.WearUserAvatarEquip(player.PlayerID, avatar.AvatarId, weapon.WeaponId)
|
|
||||||
|
|
||||||
wearEquipRsp := &proto.WearEquipRsp{
|
|
||||||
AvatarGuid: avatarGuid,
|
|
||||||
EquipGuid: equipGuid,
|
|
||||||
}
|
|
||||||
g.SendMsg(cmd.WearEquipRsp, player.PlayerID, player.ClientSeq, wearEquipRsp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weaponId uint64) {
|
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
|
||||||
if player == nil {
|
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
avatar := player.AvatarMap[avatarId]
|
|
||||||
weapon := player.WeaponMap[weaponId]
|
|
||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
|
||||||
scene := world.GetSceneById(player.SceneId)
|
|
||||||
|
|
||||||
if weapon.AvatarId != 0 {
|
|
||||||
// 武器在别的角色身上
|
|
||||||
weakAvatarId := weapon.AvatarId
|
|
||||||
weakWeaponId := weaponId
|
|
||||||
strongAvatarId := avatarId
|
|
||||||
strongWeaponId := avatar.EquipWeapon.WeaponId
|
|
||||||
player.TakeOffWeapon(weakAvatarId, weakWeaponId)
|
|
||||||
player.TakeOffWeapon(strongAvatarId, strongWeaponId)
|
|
||||||
player.WearWeapon(weakAvatarId, strongWeaponId)
|
|
||||||
player.WearWeapon(strongAvatarId, weakWeaponId)
|
|
||||||
|
|
||||||
weakAvatar := player.AvatarMap[weakAvatarId]
|
|
||||||
weakWeapon := player.WeaponMap[weakAvatar.EquipWeapon.WeaponId]
|
|
||||||
|
|
||||||
weakWorldAvatar := world.GetPlayerWorldAvatar(player, weakAvatarId)
|
|
||||||
if weakWorldAvatar != nil {
|
|
||||||
weakWorldAvatar.SetWeaponEntityId(scene.CreateEntityWeapon())
|
|
||||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, weakWorldAvatar.GetWeaponEntityId())
|
|
||||||
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
|
||||||
} else {
|
|
||||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, 0)
|
|
||||||
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
|
||||||
}
|
|
||||||
} else if avatar.EquipWeapon != nil {
|
|
||||||
// 角色当前有武器
|
|
||||||
player.TakeOffWeapon(avatarId, avatar.EquipWeapon.WeaponId)
|
|
||||||
player.WearWeapon(avatarId, weaponId)
|
|
||||||
} else {
|
|
||||||
// 是新角色还没有武器
|
|
||||||
player.WearWeapon(avatarId, weaponId)
|
|
||||||
}
|
|
||||||
|
|
||||||
worldAvatar := world.GetPlayerWorldAvatar(player, avatarId)
|
|
||||||
if worldAvatar != nil {
|
|
||||||
worldAvatar.SetWeaponEntityId(scene.CreateEntityWeapon())
|
|
||||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, worldAvatar.GetWeaponEntityId())
|
|
||||||
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
|
||||||
} else {
|
|
||||||
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, 0)
|
|
||||||
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
logger.Debug("user change avatar costume, uid: %v", player.PlayerID)
|
logger.Debug("user change avatar costume, uid: %v", player.PlayerID)
|
||||||
req := payloadMsg.(*proto.AvatarChangeCostumeReq)
|
req := payloadMsg.(*proto.AvatarChangeCostumeReq)
|
||||||
@@ -515,45 +434,6 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
|
|||||||
g.SendMsg(cmd.AvatarWearFlycloakRsp, player.PlayerID, player.ClientSeq, avatarWearFlycloakRsp)
|
g.SendMsg(cmd.AvatarWearFlycloakRsp, player.PlayerID, player.ClientSeq, avatarWearFlycloakRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon *model.Weapon, entityId uint32) *proto.AvatarEquipChangeNotify {
|
|
||||||
itemDataConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
|
||||||
if itemDataConfig == nil {
|
|
||||||
logger.Error("item data config error, itemId: %v", weapon.ItemId)
|
|
||||||
return new(proto.AvatarEquipChangeNotify)
|
|
||||||
}
|
|
||||||
avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
|
|
||||||
AvatarGuid: avatar.Guid,
|
|
||||||
ItemId: weapon.ItemId,
|
|
||||||
EquipGuid: weapon.Guid,
|
|
||||||
}
|
|
||||||
switch itemDataConfig.Type {
|
|
||||||
case int32(constant.ITEM_TYPE_WEAPON):
|
|
||||||
avatarEquipChangeNotify.EquipType = uint32(constant.EQUIP_TYPE_WEAPON)
|
|
||||||
case int32(constant.ITEM_TYPE_RELIQUARY):
|
|
||||||
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.ReliquaryType)
|
|
||||||
}
|
|
||||||
avatarEquipChangeNotify.Weapon = &proto.SceneWeaponInfo{
|
|
||||||
EntityId: entityId,
|
|
||||||
GadgetId: uint32(itemDataConfig.GadgetId),
|
|
||||||
ItemId: weapon.ItemId,
|
|
||||||
Guid: weapon.Guid,
|
|
||||||
Level: uint32(weapon.Level),
|
|
||||||
AbilityInfo: new(proto.AbilitySyncStateInfo),
|
|
||||||
}
|
|
||||||
return avatarEquipChangeNotify
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GameManager) PacketAvatarEquipTakeOffNotify(avatar *model.Avatar, weapon *model.Weapon) *proto.AvatarEquipChangeNotify {
|
|
||||||
avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
|
|
||||||
AvatarGuid: avatar.Guid,
|
|
||||||
}
|
|
||||||
itemDataConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
|
||||||
if itemDataConfig != nil {
|
|
||||||
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.Type)
|
|
||||||
}
|
|
||||||
return avatarEquipChangeNotify
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GameManager) UpdateUserAvatarFightProp(userId uint32, avatarId uint32) {
|
func (g *GameManager) UpdateUserAvatarFightProp(userId uint32, avatarId uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
|
|||||||
179
gs/game/player_equip.go
Normal file
179
gs/game/player_equip.go
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hk4e/common/constant"
|
||||||
|
"hk4e/gdconf"
|
||||||
|
"hk4e/gs/model"
|
||||||
|
"hk4e/pkg/logger"
|
||||||
|
"hk4e/protocol/cmd"
|
||||||
|
"hk4e/protocol/proto"
|
||||||
|
|
||||||
|
pb "google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetEquipLockStateReq 设置装备上锁状态请求
|
||||||
|
func (g *GameManager) SetEquipLockStateReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
|
logger.Debug("user set equip lock, uid: %v", player.PlayerID)
|
||||||
|
req := payloadMsg.(*proto.SetEquipLockStateReq)
|
||||||
|
|
||||||
|
// 获取目标装备
|
||||||
|
equipGameObj, ok := player.GameObjectGuidMap[req.TargetEquipGuid]
|
||||||
|
if !ok {
|
||||||
|
logger.Error("equip error, equipGuid: %v", req.TargetEquipGuid)
|
||||||
|
g.SendError(cmd.SetEquipLockStateRsp, player, &proto.SetEquipLockStateRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch equipGameObj.(type) {
|
||||||
|
case *model.Weapon:
|
||||||
|
weapon := equipGameObj.(*model.Weapon)
|
||||||
|
weapon.Lock = req.IsLocked
|
||||||
|
// 更新武器的物品数据
|
||||||
|
g.SendMsg(cmd.StoreItemChangeNotify, player.PlayerID, player.ClientSeq, g.PacketStoreItemChangeNotifyByWeapon(weapon))
|
||||||
|
case *model.Reliquary:
|
||||||
|
reliquary := equipGameObj.(*model.Reliquary)
|
||||||
|
reliquary.Lock = req.IsLocked
|
||||||
|
// TODO 更新圣遗物的物品数据
|
||||||
|
default:
|
||||||
|
logger.Error("equip type error, equipGuid: %v", req.TargetEquipGuid)
|
||||||
|
g.SendError(cmd.SetEquipLockStateRsp, player, &proto.SetEquipLockStateRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setEquipLockStateRsp := &proto.SetEquipLockStateRsp{
|
||||||
|
TargetEquipGuid: req.TargetEquipGuid,
|
||||||
|
IsLocked: req.IsLocked,
|
||||||
|
}
|
||||||
|
g.SendMsg(cmd.SetEquipLockStateRsp, player.PlayerID, player.ClientSeq, setEquipLockStateRsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WearEquipReq 穿戴装备请求
|
||||||
|
func (g *GameManager) WearEquipReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
|
logger.Debug("user wear equip, uid: %v", player.PlayerID)
|
||||||
|
req := payloadMsg.(*proto.WearEquipReq)
|
||||||
|
|
||||||
|
avatar, ok := player.AvatarMap[player.GetAvatarIdByGuid(req.AvatarGuid)]
|
||||||
|
if !ok {
|
||||||
|
logger.Error("avatar error, avatarGuid: %v", req.AvatarGuid)
|
||||||
|
g.SendError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{}, proto.Retcode_RET_CAN_NOT_FIND_AVATAR)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 获取目标装备
|
||||||
|
equipGameObj, ok := player.GameObjectGuidMap[req.EquipGuid]
|
||||||
|
if !ok {
|
||||||
|
logger.Error("equip error, equipGuid: %v", req.EquipGuid)
|
||||||
|
g.SendError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch equipGameObj.(type) {
|
||||||
|
case *model.Weapon:
|
||||||
|
weapon := equipGameObj.(*model.Weapon)
|
||||||
|
g.WearUserAvatarWeapon(player.PlayerID, avatar.AvatarId, weapon.WeaponId)
|
||||||
|
case *model.Reliquary:
|
||||||
|
// 暂时不写
|
||||||
|
default:
|
||||||
|
logger.Error("equip type error, equipGuid: %v", req.EquipGuid)
|
||||||
|
g.SendError(cmd.WearEquipRsp, player, &proto.WearEquipRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
wearEquipRsp := &proto.WearEquipRsp{
|
||||||
|
AvatarGuid: req.AvatarGuid,
|
||||||
|
EquipGuid: req.EquipGuid,
|
||||||
|
}
|
||||||
|
g.SendMsg(cmd.WearEquipRsp, player.PlayerID, player.ClientSeq, wearEquipRsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WearUserAvatarWeapon 玩家角色装备武器
|
||||||
|
func (g *GameManager) WearUserAvatarWeapon(userId uint32, avatarId uint32, weaponId uint64) {
|
||||||
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
|
if player == nil {
|
||||||
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
avatar := player.AvatarMap[avatarId]
|
||||||
|
weapon := player.WeaponMap[weaponId]
|
||||||
|
|
||||||
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
|
||||||
|
if weapon.AvatarId != 0 {
|
||||||
|
// 武器在别的角色身上
|
||||||
|
weakAvatarId := weapon.AvatarId
|
||||||
|
weakWeaponId := weaponId
|
||||||
|
strongAvatarId := avatarId
|
||||||
|
strongWeaponId := avatar.EquipWeapon.WeaponId
|
||||||
|
player.TakeOffWeapon(weakAvatarId, weakWeaponId)
|
||||||
|
player.TakeOffWeapon(strongAvatarId, strongWeaponId)
|
||||||
|
player.WearWeapon(weakAvatarId, strongWeaponId)
|
||||||
|
player.WearWeapon(strongAvatarId, weakWeaponId)
|
||||||
|
|
||||||
|
weakAvatar := player.AvatarMap[weakAvatarId]
|
||||||
|
weakWeapon := player.WeaponMap[weakAvatar.EquipWeapon.WeaponId]
|
||||||
|
|
||||||
|
weakWorldAvatar := world.GetPlayerWorldAvatar(player, weakAvatarId)
|
||||||
|
if weakWorldAvatar != nil {
|
||||||
|
weakWorldAvatar.SetWeaponEntityId(scene.CreateEntityWeapon())
|
||||||
|
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, weakWorldAvatar.GetWeaponEntityId())
|
||||||
|
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
||||||
|
} else {
|
||||||
|
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, 0)
|
||||||
|
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
||||||
|
}
|
||||||
|
} else if avatar.EquipWeapon != nil {
|
||||||
|
// 角色当前有武器
|
||||||
|
player.TakeOffWeapon(avatarId, avatar.EquipWeapon.WeaponId)
|
||||||
|
player.WearWeapon(avatarId, weaponId)
|
||||||
|
} else {
|
||||||
|
// 是新角色还没有武器
|
||||||
|
player.WearWeapon(avatarId, weaponId)
|
||||||
|
}
|
||||||
|
|
||||||
|
worldAvatar := world.GetPlayerWorldAvatar(player, avatarId)
|
||||||
|
if worldAvatar != nil {
|
||||||
|
worldAvatar.SetWeaponEntityId(scene.CreateEntityWeapon())
|
||||||
|
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, worldAvatar.GetWeaponEntityId())
|
||||||
|
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
||||||
|
} else {
|
||||||
|
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, 0)
|
||||||
|
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon *model.Weapon, entityId uint32) *proto.AvatarEquipChangeNotify {
|
||||||
|
itemDataConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
||||||
|
if itemDataConfig == nil {
|
||||||
|
logger.Error("item data config error, itemId: %v", weapon.ItemId)
|
||||||
|
return new(proto.AvatarEquipChangeNotify)
|
||||||
|
}
|
||||||
|
avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
|
||||||
|
AvatarGuid: avatar.Guid,
|
||||||
|
ItemId: weapon.ItemId,
|
||||||
|
EquipGuid: weapon.Guid,
|
||||||
|
}
|
||||||
|
switch itemDataConfig.Type {
|
||||||
|
case int32(constant.ITEM_TYPE_WEAPON):
|
||||||
|
avatarEquipChangeNotify.EquipType = uint32(constant.EQUIP_TYPE_WEAPON)
|
||||||
|
case int32(constant.ITEM_TYPE_RELIQUARY):
|
||||||
|
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.ReliquaryType)
|
||||||
|
}
|
||||||
|
avatarEquipChangeNotify.Weapon = &proto.SceneWeaponInfo{
|
||||||
|
EntityId: entityId,
|
||||||
|
GadgetId: uint32(itemDataConfig.GadgetId),
|
||||||
|
ItemId: weapon.ItemId,
|
||||||
|
Guid: weapon.Guid,
|
||||||
|
Level: uint32(weapon.Level),
|
||||||
|
AbilityInfo: new(proto.AbilitySyncStateInfo),
|
||||||
|
}
|
||||||
|
return avatarEquipChangeNotify
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *GameManager) PacketAvatarEquipTakeOffNotify(avatar *model.Avatar, weapon *model.Weapon) *proto.AvatarEquipChangeNotify {
|
||||||
|
avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
|
||||||
|
AvatarGuid: avatar.Guid,
|
||||||
|
}
|
||||||
|
itemDataConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
||||||
|
if itemDataConfig != nil {
|
||||||
|
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.Type)
|
||||||
|
}
|
||||||
|
return avatarEquipChangeNotify
|
||||||
|
}
|
||||||
@@ -136,12 +136,23 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
|
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 确保获取消耗的摩拉索引不越界
|
||||||
|
if int(weapon.Refinement) >= len(weaponConfig.AwakenCoinCostList) {
|
||||||
|
logger.Error("weapon config cost coin error, itemId: %v", weapon.ItemId)
|
||||||
|
return
|
||||||
|
}
|
||||||
// 摩拉数量是否足够
|
// 摩拉数量是否足够
|
||||||
if player.GetItemCount(constant.ITEM_ID_SCOIN) < weaponConfig.AwakenCoinCostList[weapon.Refinement] {
|
if player.GetItemCount(constant.ITEM_ID_SCOIN) < weaponConfig.AwakenCoinCostList[weapon.Refinement] {
|
||||||
logger.Error("item count not enough, itemId: %v", constant.ITEM_ID_SCOIN)
|
logger.Error("item count not enough, itemId: %v", constant.ITEM_ID_SCOIN)
|
||||||
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
|
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 一星二星的武器不能精炼
|
||||||
|
if weaponConfig.EquipLevel < 3 {
|
||||||
|
logger.Error("weapon equip level le 3, itemId: %v", weapon.ItemId)
|
||||||
|
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_AWAKEN_LEVEL_MAX)
|
||||||
|
return
|
||||||
|
}
|
||||||
// 武器精炼等级是否不超过限制
|
// 武器精炼等级是否不超过限制
|
||||||
// 暂时精炼等级是写死的 应该最大精炼等级就是5级
|
// 暂时精炼等级是写死的 应该最大精炼等级就是5级
|
||||||
if weapon.Refinement >= 4 {
|
if weapon.Refinement >= 4 {
|
||||||
@@ -174,6 +185,12 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_EQUIP_HAS_BEEN_WEARED)
|
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_EQUIP_HAS_BEEN_WEARED)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 确保被精炼武器没有上锁
|
||||||
|
if foodWeapon.Lock {
|
||||||
|
logger.Error("food weapon has been lock, weaponGuid: %v", req.ItemGuid)
|
||||||
|
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_EQUIP_IS_LOCKED)
|
||||||
|
return
|
||||||
|
}
|
||||||
// 消耗作为精炼材料的武器
|
// 消耗作为精炼材料的武器
|
||||||
g.CostUserWeapon(player.PlayerID, []uint64{foodWeapon.WeaponId})
|
g.CostUserWeapon(player.PlayerID, []uint64{foodWeapon.WeaponId})
|
||||||
case int32(constant.ITEM_TYPE_MATERIAL):
|
case int32(constant.ITEM_TYPE_MATERIAL):
|
||||||
@@ -584,6 +601,18 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
logger.Error("food weapon error, weaponGuid: %v", weaponGuid)
|
logger.Error("food weapon error, weaponGuid: %v", weaponGuid)
|
||||||
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
|
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
|
||||||
}
|
}
|
||||||
|
// 确保被精炼武器没有被任何角色装备
|
||||||
|
if foodWeapon.AvatarId != 0 {
|
||||||
|
logger.Error("food weapon has been wear, weaponGuid: %v", weaponGuid)
|
||||||
|
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_EQUIP_HAS_BEEN_WEARED)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 确保被精炼武器没有上锁
|
||||||
|
if foodWeapon.Lock {
|
||||||
|
logger.Error("food weapon has been lock, weaponGuid: %v", weaponGuid)
|
||||||
|
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_EQUIP_IS_LOCKED)
|
||||||
|
return
|
||||||
|
}
|
||||||
costWeaponIdList = append(costWeaponIdList, foodWeapon.WeaponId)
|
costWeaponIdList = append(costWeaponIdList, foodWeapon.WeaponId)
|
||||||
}
|
}
|
||||||
// 消耗升级材料和摩拉
|
// 消耗升级材料和摩拉
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ func (r *RouteManager) initRoute() {
|
|||||||
r.registerRouter(cmd.WeaponPromoteReq, GAME_MANAGER.WeaponPromoteReq)
|
r.registerRouter(cmd.WeaponPromoteReq, GAME_MANAGER.WeaponPromoteReq)
|
||||||
r.registerRouter(cmd.WeaponAwakenReq, GAME_MANAGER.WeaponAwakenReq)
|
r.registerRouter(cmd.WeaponAwakenReq, GAME_MANAGER.WeaponAwakenReq)
|
||||||
r.registerRouter(cmd.AvatarPromoteGetRewardReq, GAME_MANAGER.AvatarPromoteGetRewardReq)
|
r.registerRouter(cmd.AvatarPromoteGetRewardReq, GAME_MANAGER.AvatarPromoteGetRewardReq)
|
||||||
|
r.registerRouter(cmd.SetEquipLockStateReq, GAME_MANAGER.SetEquipLockStateReq)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RouteManager) RouteHandle(netMsg *mq.NetMsg) {
|
func (r *RouteManager) RouteHandle(netMsg *mq.NetMsg) {
|
||||||
|
|||||||
@@ -248,6 +248,8 @@ func (c *CmdProtoMap) registerAllMessage() {
|
|||||||
c.registerMessage(WeaponPromoteRsp, &proto.WeaponPromoteRsp{}) // 武器突破响应
|
c.registerMessage(WeaponPromoteRsp, &proto.WeaponPromoteRsp{}) // 武器突破响应
|
||||||
c.registerMessage(WeaponAwakenReq, &proto.WeaponAwakenReq{}) // 武器精炼请求
|
c.registerMessage(WeaponAwakenReq, &proto.WeaponAwakenReq{}) // 武器精炼请求
|
||||||
c.registerMessage(WeaponAwakenRsp, &proto.WeaponAwakenRsp{}) // 武器精炼响应
|
c.registerMessage(WeaponAwakenRsp, &proto.WeaponAwakenRsp{}) // 武器精炼响应
|
||||||
|
c.registerMessage(SetEquipLockStateReq, &proto.SetEquipLockStateReq{}) // 设置装备上锁状态请求
|
||||||
|
c.registerMessage(SetEquipLockStateRsp, &proto.SetEquipLockStateRsp{}) // 设置装备上锁状态响应
|
||||||
|
|
||||||
// 商店
|
// 商店
|
||||||
c.registerMessage(GetShopmallDataReq, &proto.GetShopmallDataReq{}) // 商店信息请求
|
c.registerMessage(GetShopmallDataReq, &proto.GetShopmallDataReq{}) // 商店信息请求
|
||||||
|
|||||||
Reference in New Issue
Block a user