2020-02-01 18:55:56 -05:00
|
|
|
package d2inventory
|
2019-11-14 22:20:01 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2020-01-31 23:18:11 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
2020-01-26 00:39:13 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
2019-11-14 22:20:01 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type InventoryItemArmor struct {
|
2020-06-13 18:32:09 -04:00
|
|
|
InventorySizeX int `json:"inventorySizeX"`
|
|
|
|
InventorySizeY int `json:"inventorySizeY"`
|
|
|
|
InventorySlotX int `json:"inventorySlotX"`
|
|
|
|
InventorySlotY int `json:"inventorySlotY"`
|
|
|
|
ItemName string `json:"itemName"`
|
|
|
|
ItemCode string `json:"itemCode"`
|
|
|
|
ArmorClass string `json:"armorClass"`
|
2019-11-14 22:20:01 -05:00
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func GetArmorItemByCode(code string) *InventoryItemArmor {
|
2019-11-14 22:20:01 -05:00
|
|
|
result := d2datadict.Armors[code]
|
|
|
|
if result == nil {
|
|
|
|
log.Fatalf("Could not find armor entry for code '%s'", code)
|
|
|
|
}
|
2019-12-28 23:32:53 -05:00
|
|
|
return &InventoryItemArmor{
|
2020-06-13 18:32:09 -04:00
|
|
|
InventorySizeX: result.InventoryWidth,
|
|
|
|
InventorySizeY: result.InventoryHeight,
|
|
|
|
ItemName: result.Name,
|
|
|
|
ItemCode: result.Code,
|
|
|
|
ArmorClass: "lit", // TODO: Where does this come from?
|
2019-11-14 22:20:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-13 18:32:09 -04:00
|
|
|
func (v *InventoryItemArmor) GetArmorClass() string {
|
|
|
|
if v == nil || v.ItemCode == "" {
|
2019-11-14 22:20:01 -05:00
|
|
|
return "lit"
|
|
|
|
}
|
2020-06-13 18:32:09 -04:00
|
|
|
return v.ArmorClass
|
2019-11-14 22:20:01 -05:00
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemArmor) InventoryItemName() string {
|
|
|
|
if v == nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2020-06-13 18:32:09 -04:00
|
|
|
return v.ItemName
|
2019-11-14 22:20:01 -05:00
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemArmor) InventoryItemType() d2enum.InventoryItemType {
|
2019-11-14 22:20:01 -05:00
|
|
|
return d2enum.InventoryItemTypeArmor
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemArmor) InventoryGridSize() (int, int) {
|
2020-06-13 18:32:09 -04:00
|
|
|
return v.InventorySizeX, v.InventorySizeY
|
2019-11-14 22:20:01 -05:00
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemArmor) InventoryGridSlot() (int, int) {
|
2020-06-13 18:32:09 -04:00
|
|
|
return v.InventorySlotX, v.InventorySlotY
|
2019-12-28 23:32:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *InventoryItemArmor) SetInventoryGridSlot(x int, y int) {
|
2020-06-13 18:32:09 -04:00
|
|
|
v.InventorySlotX, v.InventorySlotY = x, y
|
2019-12-28 23:32:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *InventoryItemArmor) Serialize() []byte {
|
2019-11-14 22:20:01 -05:00
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
|
2020-06-13 18:32:09 -04:00
|
|
|
func (v *InventoryItemArmor) GetItemCode() string {
|
2019-12-28 23:32:53 -05:00
|
|
|
if v == nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2020-06-13 18:32:09 -04:00
|
|
|
return v.ItemCode
|
2019-11-14 22:20:01 -05:00
|
|
|
}
|