修复圣遗物替换的小问题并优化

This commit is contained in:
UnKownOwO
2023-02-15 21:02:46 +08:00
parent 76b417f3f4
commit 555463f669
8 changed files with 97 additions and 90 deletions

View File

@@ -80,15 +80,6 @@ func (p *Player) InitAvatarFightProp(avatar *Avatar) {
p.SetCurrEnergy(avatar, avatar.CurrEnergy, true)
}
func (p *Player) GetAvatarIdByGuid(guid uint64) uint32 {
for avatarId, avatar := range p.AvatarMap {
if guid == avatar.Guid {
return avatarId
}
}
return 0
}
func (p *Player) AddAvatar(avatarId uint32) {
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatarId))
if avatarDataConfig == nil {

View File

@@ -11,6 +11,7 @@ type Item struct {
func (p *Player) InitAllItem() {
for itemId, item := range p.ItemMap {
item.Guid = p.GetNextGameObjectGuid()
p.GameObjectGuidMap[item.Guid] = GameObject(item)
p.ItemMap[itemId] = item
}
}
@@ -23,28 +24,6 @@ func (p *Player) GetItemGuid(itemId uint32) uint64 {
return itemInfo.Guid
}
func (p *Player) GetItemIdByGuid(itemGuid uint64) uint32 {
for _, item := range p.ItemMap {
if item.Guid == itemGuid {
return item.ItemId
}
}
return 0
}
func (p *Player) GetItemIdByItemAndWeaponGuid(guid uint64) uint32 {
for _, item := range p.ItemMap {
if item.Guid == guid {
return item.ItemId
}
}
for _, weapon := range p.WeaponMap {
if weapon.Guid == guid {
return weapon.ItemId
}
}
return 0
}
func (p *Player) GetItemCount(itemId uint32) uint32 {
prop, ok := constant.VIRTUAL_ITEM_PROP[itemId]
if ok {
@@ -72,6 +51,7 @@ func (p *Player) AddItem(itemId uint32, count uint32) {
Count: 0,
Guid: p.GetNextGameObjectGuid(),
}
p.GameObjectGuidMap[itemInfo.Guid] = GameObject(itemInfo)
}
itemInfo.Count += count
p.ItemMap[itemId] = itemInfo
@@ -89,6 +69,7 @@ func (p *Player) CostItem(itemId uint32, count uint32) {
}
if itemInfo.Count == 0 {
delete(p.ItemMap, itemId)
delete(p.GameObjectGuidMap, itemInfo.Guid)
} else {
p.ItemMap[itemId] = itemInfo
}

View File

@@ -50,15 +50,6 @@ func (p *Player) GetReliquaryGuid(reliquaryId uint64) uint64 {
return reliquaryInfo.Guid
}
func (p *Player) GetReliquaryIdByGuid(guid uint64) uint64 {
for reliquaryId, reliquary := range p.ReliquaryMap {
if guid == reliquary.Guid {
return reliquaryId
}
}
return 0
}
func (p *Player) GetReliquary(reliquaryId uint64) *Reliquary {
return p.ReliquaryMap[reliquaryId]
}
@@ -96,5 +87,6 @@ func (p *Player) CostReliquary(reliquaryId uint64) uint64 {
return 0
}
delete(p.ReliquaryMap, reliquaryId)
delete(p.GameObjectGuidMap, reliquary.Guid)
return reliquary.Guid
}

View File

@@ -44,15 +44,6 @@ func (p *Player) GetWeaponGuid(weaponId uint64) uint64 {
return weaponInfo.Guid
}
func (p *Player) GetWeaponIdByGuid(guid uint64) uint64 {
for weaponId, weapon := range p.WeaponMap {
if guid == weapon.Guid {
return weaponId
}
}
return 0
}
func (p *Player) GetWeapon(weaponId uint64) *Weapon {
return p.WeaponMap[weaponId]
}
@@ -91,5 +82,6 @@ func (p *Player) CostWeapon(weaponId uint64) uint64 {
return 0
}
delete(p.WeaponMap, weaponId)
delete(p.GameObjectGuidMap, weapon.Guid)
return weapon.Guid
}