2019-01-06 23:00:24 +03:00
|
|
|
package mapblockparser
|
|
|
|
|
|
|
|
|
|
|
|
type MapBlock struct {
|
|
|
|
Version byte
|
|
|
|
Underground bool
|
|
|
|
Mapdata []byte
|
|
|
|
Metadata Metadata
|
2019-01-07 10:59:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type Metadata struct {
|
2019-01-07 18:06:03 +03:00
|
|
|
Inventories map[int]map[string]*Inventory
|
2019-01-07 18:35:26 +03:00
|
|
|
Pairs map[int]map[string]string
|
2019-01-07 18:06:03 +03:00
|
|
|
}
|
|
|
|
|
2019-01-07 18:35:26 +03:00
|
|
|
func (md *Metadata) GetPairsMap(pos int) map[string]string {
|
2019-01-07 18:06:03 +03:00
|
|
|
if md.Pairs == nil {
|
2019-01-07 18:35:26 +03:00
|
|
|
md.Pairs = make(map[int]map[string]string)
|
2019-01-07 18:06:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pairsMap := md.Pairs[pos]
|
|
|
|
if pairsMap == nil {
|
2019-01-07 18:35:26 +03:00
|
|
|
pairsMap = make(map[string]string)
|
2019-01-07 18:06:03 +03:00
|
|
|
md.Pairs[pos] = pairsMap
|
|
|
|
}
|
|
|
|
|
|
|
|
return pairsMap
|
|
|
|
}
|
|
|
|
|
|
|
|
func (md *Metadata) GetInventoryMap(pos int) map[string]*Inventory {
|
|
|
|
invMap := md.Inventories[pos]
|
|
|
|
if invMap == nil {
|
|
|
|
invMap = make(map[string]*Inventory)
|
|
|
|
md.Inventories[pos] = invMap
|
|
|
|
}
|
|
|
|
|
|
|
|
return invMap
|
|
|
|
}
|
|
|
|
|
|
|
|
func (md *Metadata) GetInventory(pos int, name string) *Inventory {
|
|
|
|
m := md.GetInventoryMap(pos)
|
|
|
|
inv := m[name]
|
|
|
|
if inv == nil {
|
|
|
|
inv = &Inventory{}
|
|
|
|
m[name] = inv
|
|
|
|
}
|
|
|
|
|
|
|
|
return inv
|
2019-01-07 10:59:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type Item struct {
|
|
|
|
Name string
|
|
|
|
Count int
|
|
|
|
Wear int
|
|
|
|
}
|
|
|
|
|
|
|
|
type Inventory struct {
|
|
|
|
Size int
|
|
|
|
Items []Item
|
2019-01-06 23:00:24 +03:00
|
|
|
}
|