mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-23 14:32:27 +08:00
修复圣遗物替换的小问题并优化
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user