feat(npc): add preset unit helper to retrieve npc from 1.13c map data
This commit is contained in:
@@ -2,9 +2,11 @@ package data
|
||||
|
||||
import (
|
||||
"github.com/hectorgimenez/d2go/pkg/data/mode"
|
||||
"github.com/hectorgimenez/d2go/pkg/data/monplace"
|
||||
"github.com/hectorgimenez/d2go/pkg/data/npc"
|
||||
"github.com/hectorgimenez/d2go/pkg/data/stat"
|
||||
"github.com/hectorgimenez/d2go/pkg/data/state"
|
||||
"github.com/hectorgimenez/d2go/pkg/data/superunique"
|
||||
)
|
||||
|
||||
type NPC struct {
|
||||
@@ -39,6 +41,32 @@ func (n NPCs) FindOne(npcid npc.ID) (NPC, bool) {
|
||||
return NPC{}, false
|
||||
}
|
||||
|
||||
func (n NPCs) FindOneBySuperUniqueID(id superunique.ID) (NPC, bool) {
|
||||
presetunit, found := npc.PresetUnitForSuperUniqueID(id)
|
||||
if found {
|
||||
for _, np := range n {
|
||||
if np.ID == npc.ID(presetunit.PresetID) {
|
||||
return np, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NPC{}, false
|
||||
}
|
||||
|
||||
func (n NPCs) FindOneByMonPlaceID(id monplace.ID) (NPC, bool) {
|
||||
presetunit, found := npc.PresetUnitForMonPlaceID(id)
|
||||
if found {
|
||||
for _, np := range n {
|
||||
if np.ID == npc.ID(presetunit.PresetID) {
|
||||
return np, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NPC{}, false
|
||||
}
|
||||
|
||||
func (m Monsters) FindOne(id npc.ID, t MonsterType) (Monster, bool) {
|
||||
for _, monster := range m {
|
||||
if monster.Name == id {
|
||||
|
||||
Reference in New Issue
Block a user