mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-17 00:22:26 +08:00
背包容量限制
This commit is contained in:
@@ -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