-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathitem.go
63 lines (58 loc) · 1.45 KB
/
item.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package wow
import (
"encoding/json"
)
type Item struct {
Icon string
Id int
Name string
Quality int
TooltipParams *TooltipParams
BonusStats []*Stat
Stats []*Stat
Armor int
BaseArmor int
WeaponInfo *WeaponInfo
BuyPrice int
ContainerSlots int
Description string
DisenchantingSkillRank int
DisplayInfoId int
Equipable bool
HasSockets bool
HeroicTooltip bool
InventoryType int
IsAuctionable bool
ItemBind int
ItemClass int
ItemLevel int
ItemSource *ItemSource
ItemSpells []*Spell
ItemSubclass int
MaxCount int
MaxDurability int
MinFactionId int
MinReputation int
NameDescription string
NameDescriptionColor string
RequiredLevel int
RequiredSkill int
RequiredSkillRank int
SellPrice int
Stackable int
Upgradable bool
}
func NewItemFromJson(jsonBlob []byte) (*Item, error) {
item := &Item{}
err := json.Unmarshal(jsonBlob, item)
if err != nil {
return nil, err
}
if len(item.Stats) == 0 {
item.Stats = item.BonusStats
}
if len(item.BonusStats) == 0 {
item.BonusStats = item.Stats
}
return item, nil
}