mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
背包容量限制
This commit is contained in:
9
common/constant/store_pack_limit.go
Normal file
9
common/constant/store_pack_limit.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
STORE_PACK_LIMIT_WEIGHT = 30000 // 背包重量限制
|
||||
STORE_PACK_LIMIT_WEAPON = 2000 // 武器容量限制
|
||||
STORE_PACK_LIMIT_RELIQUARY = 1500 // 圣遗物容量限制
|
||||
STORE_PACK_LIMIT_MATERIAL = 2000 // 材料容量限制
|
||||
STORE_PACK_LIMIT_FURNITURE = 2000 // 家具容量限制
|
||||
)
|
||||
6
common/constant/weapon_awaken.go
Normal file
6
common/constant/weapon_awaken.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
WEAPON_AWAKEN_MAX_REFINEMENT = 5 // 武器最大精炼等级
|
||||
WEAPON_AWAKEN_MIN_EQUIPLEVEL = 3 // 武器精炼最小星级
|
||||
)
|
||||
@@ -185,11 +185,11 @@ func (g *GameManager) PacketStoreWeightLimitNotify() *proto.StoreWeightLimitNoti
|
||||
storeWeightLimitNotify := &proto.StoreWeightLimitNotify{
|
||||
StoreType: proto.StoreType_STORE_PACK,
|
||||
// 背包容量限制
|
||||
WeightLimit: 30000,
|
||||
WeaponCountLimit: 2000,
|
||||
ReliquaryCountLimit: 1500,
|
||||
MaterialCountLimit: 2000,
|
||||
FurnitureCountLimit: 2000,
|
||||
WeightLimit: constant.STORE_PACK_LIMIT_WEIGHT,
|
||||
WeaponCountLimit: constant.STORE_PACK_LIMIT_WEAPON,
|
||||
ReliquaryCountLimit: constant.STORE_PACK_LIMIT_RELIQUARY,
|
||||
MaterialCountLimit: constant.STORE_PACK_LIMIT_MATERIAL,
|
||||
FurnitureCountLimit: constant.STORE_PACK_LIMIT_FURNITURE,
|
||||
}
|
||||
return storeWeightLimitNotify
|
||||
}
|
||||
@@ -197,14 +197,10 @@ func (g *GameManager) PacketStoreWeightLimitNotify() *proto.StoreWeightLimitNoti
|
||||
func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.PlayerStoreNotify {
|
||||
playerStoreNotify := &proto.PlayerStoreNotify{
|
||||
StoreType: proto.StoreType_STORE_PACK,
|
||||
WeightLimit: 30000,
|
||||
WeightLimit: constant.STORE_PACK_LIMIT_WEIGHT,
|
||||
ItemList: make([]*proto.Item, 0, len(player.WeaponMap)+len(player.ReliquaryMap)+len(player.ItemMap)),
|
||||
}
|
||||
for _, weapon := range player.WeaponMap {
|
||||
pbItem := &proto.Item{
|
||||
ItemId: weapon.ItemId,
|
||||
Guid: weapon.Guid,
|
||||
Detail: nil,
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("get item data config is nil, itemId: %v", weapon.ItemId)
|
||||
@@ -217,27 +213,26 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
|
||||
for _, affixId := range weapon.AffixIdList {
|
||||
affixMap[affixId] = uint32(weapon.Refinement)
|
||||
}
|
||||
pbItem.Detail = &proto.Item_Equip{
|
||||
Equip: &proto.Equip{
|
||||
Detail: &proto.Equip_Weapon{
|
||||
Weapon: &proto.Weapon{
|
||||
Level: uint32(weapon.Level),
|
||||
Exp: weapon.Exp,
|
||||
PromoteLevel: uint32(weapon.Promote),
|
||||
AffixMap: affixMap,
|
||||
pbItem := &proto.Item{
|
||||
ItemId: weapon.ItemId,
|
||||
Guid: weapon.Guid,
|
||||
Detail: &proto.Item_Equip{
|
||||
Equip: &proto.Equip{
|
||||
Detail: &proto.Equip_Weapon{
|
||||
Weapon: &proto.Weapon{
|
||||
Level: uint32(weapon.Level),
|
||||
Exp: weapon.Exp,
|
||||
PromoteLevel: uint32(weapon.Promote),
|
||||
AffixMap: affixMap,
|
||||
},
|
||||
},
|
||||
IsLocked: weapon.Lock,
|
||||
},
|
||||
IsLocked: weapon.Lock,
|
||||
},
|
||||
}
|
||||
playerStoreNotify.ItemList = append(playerStoreNotify.ItemList, pbItem)
|
||||
}
|
||||
for _, reliquary := range player.ReliquaryMap {
|
||||
pbItem := &proto.Item{
|
||||
ItemId: reliquary.ItemId,
|
||||
Guid: reliquary.Guid,
|
||||
Detail: nil,
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(reliquary.ItemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("get item data config is nil, itemId: %v", reliquary.ItemId)
|
||||
@@ -246,33 +241,37 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
|
||||
if uint16(itemDataConfig.Type) != constant.ITEM_TYPE_RELIQUARY {
|
||||
continue
|
||||
}
|
||||
pbItem.Detail = &proto.Item_Equip{
|
||||
Equip: &proto.Equip{
|
||||
Detail: &proto.Equip_Reliquary{
|
||||
Reliquary: &proto.Reliquary{
|
||||
Level: uint32(reliquary.Level),
|
||||
Exp: reliquary.Exp,
|
||||
PromoteLevel: uint32(reliquary.Promote),
|
||||
MainPropId: reliquary.MainPropId,
|
||||
AppendPropIdList: reliquary.AppendPropIdList,
|
||||
pbItem := &proto.Item{
|
||||
ItemId: reliquary.ItemId,
|
||||
Guid: reliquary.Guid,
|
||||
Detail: &proto.Item_Equip{
|
||||
Equip: &proto.Equip{
|
||||
Detail: &proto.Equip_Reliquary{
|
||||
Reliquary: &proto.Reliquary{
|
||||
Level: uint32(reliquary.Level),
|
||||
Exp: reliquary.Exp,
|
||||
PromoteLevel: uint32(reliquary.Promote),
|
||||
MainPropId: reliquary.MainPropId,
|
||||
AppendPropIdList: reliquary.AppendPropIdList,
|
||||
},
|
||||
},
|
||||
IsLocked: reliquary.Lock,
|
||||
},
|
||||
IsLocked: reliquary.Lock,
|
||||
},
|
||||
}
|
||||
playerStoreNotify.ItemList = append(playerStoreNotify.ItemList, pbItem)
|
||||
}
|
||||
for _, item := range player.ItemMap {
|
||||
pbItem := &proto.Item{
|
||||
ItemId: item.ItemId,
|
||||
Guid: item.Guid,
|
||||
Detail: nil,
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(item.ItemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("get item data config is nil, itemId: %v", item.ItemId)
|
||||
continue
|
||||
}
|
||||
pbItem := &proto.Item{
|
||||
ItemId: item.ItemId,
|
||||
Guid: item.Guid,
|
||||
Detail: nil,
|
||||
}
|
||||
if itemDataConfig != nil && uint16(itemDataConfig.Type) == constant.ITEM_TYPE_FURNITURE {
|
||||
pbItem.Detail = &proto.Item_Furniture{
|
||||
Furniture: &proto.Furniture{
|
||||
|
||||
@@ -148,14 +148,14 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
||||
return
|
||||
}
|
||||
// 一星二星的武器不能精炼
|
||||
if weaponConfig.EquipLevel < 3 {
|
||||
if weaponConfig.EquipLevel < constant.WEAPON_AWAKEN_MIN_EQUIPLEVEL {
|
||||
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级
|
||||
if weapon.Refinement >= 4 {
|
||||
if weapon.Refinement+1 >= constant.WEAPON_AWAKEN_MAX_REFINEMENT {
|
||||
logger.Error("weapon refinement ge 4, refinement: %v", weapon.Refinement)
|
||||
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_AWAKEN_LEVEL_MAX)
|
||||
return
|
||||
|
||||
@@ -62,6 +62,11 @@ func (p *Player) GetItemCount(itemId uint32) uint32 {
|
||||
func (p *Player) AddItem(itemId uint32, count uint32) {
|
||||
itemInfo := p.ItemMap[itemId]
|
||||
if itemInfo == nil {
|
||||
// 该物品为新物品时校验背包物品容量
|
||||
// 目前物品包括材料和家具
|
||||
if len(p.ItemMap) > constant.STORE_PACK_LIMIT_MATERIAL+constant.STORE_PACK_LIMIT_FURNITURE {
|
||||
return
|
||||
}
|
||||
itemInfo = &Item{
|
||||
ItemId: itemId,
|
||||
Count: 0,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gdconf"
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
@@ -63,6 +64,15 @@ func (p *Player) GetReliquary(reliquaryId uint64) *Reliquary {
|
||||
}
|
||||
|
||||
func (p *Player) AddReliquary(itemId uint32, reliquaryId uint64, mainPropId uint32) {
|
||||
// 校验背包圣遗物容量
|
||||
if len(p.ReliquaryMap) > constant.STORE_PACK_LIMIT_RELIQUARY {
|
||||
return
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("reliquary config is nil, itemId: %v", itemId)
|
||||
return
|
||||
}
|
||||
reliquary := &Reliquary{
|
||||
ReliquaryId: reliquaryId,
|
||||
ItemId: itemId,
|
||||
@@ -75,11 +85,6 @@ func (p *Player) AddReliquary(itemId uint32, reliquaryId uint64, mainPropId uint
|
||||
AvatarId: 0,
|
||||
Guid: 0,
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("reliquary config is nil, itemId: %v", itemId)
|
||||
return
|
||||
}
|
||||
_ = itemDataConfig
|
||||
p.InitReliquary(reliquary)
|
||||
p.ReliquaryMap[reliquaryId] = reliquary
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gdconf"
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
@@ -57,6 +58,15 @@ func (p *Player) GetWeapon(weaponId uint64) *Weapon {
|
||||
}
|
||||
|
||||
func (p *Player) AddWeapon(itemId uint32, weaponId uint64) {
|
||||
// 校验背包武器容量
|
||||
if len(p.WeaponMap) > constant.STORE_PACK_LIMIT_WEAPON {
|
||||
return
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("weapon config is nil, itemId: %v", itemId)
|
||||
return
|
||||
}
|
||||
weapon := &Weapon{
|
||||
WeaponId: weaponId,
|
||||
ItemId: itemId,
|
||||
@@ -68,11 +78,6 @@ func (p *Player) AddWeapon(itemId uint32, weaponId uint64) {
|
||||
Refinement: 0,
|
||||
Guid: 0,
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("weapon config is nil, itemId: %v", itemId)
|
||||
return
|
||||
}
|
||||
for _, skillAffix := range itemDataConfig.SkillAffix {
|
||||
weapon.AffixIdList = append(weapon.AffixIdList, uint32(skillAffix))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user