/
itemslot.go
59 lines (47 loc) · 1.09 KB
/
itemslot.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
package ospokemon
import "taylz.io/types"
const PARTitemslot = "itemslot"
type Itemslot struct {
Item *Item
Sort int
Amount int
Parts
}
func MakeItemslot() *Itemslot {
itemslot := &Itemslot{
Parts: make(Parts),
}
return itemslot
}
func BuildItemslot(item *Item, amount int) *Itemslot {
itemslot := MakeItemslot()
itemslot.Item = item
itemslot.Amount = amount
itemslot.AddPart(BuildImaging(item.Animations))
return itemslot
}
func (i *Itemslot) Part() string {
return PARTitemslot
}
func (parts Parts) GetItemslot() *Itemslot {
itemslot, _ := parts[PARTitemslot].(*Itemslot)
return itemslot
}
func (itemslot *Itemslot) Json() types.Dict {
json := types.Dict{
"item": itemslot.Item.Json(),
"amount": itemslot.Amount,
}
if imaging := itemslot.GetImaging(); imaging != nil {
json["image"] = imaging.Image
}
if entity := itemslot.GetEntity(); entity != nil {
json["entity"] = entity.Id
}
if binding := itemslot.GetBinding(); binding != nil {
json["binding"] = binding.Key
}
return json
}
// func (i *Itemslot) Update(u *Universe, e *Entity, d time.Duration) {
// }