2020-02-01 23:55:56 +00:00
|
|
|
package d2inventory
|
2019-11-15 03:20:01 +00:00
|
|
|
|
|
|
|
import (
|
2020-01-26 05:39:13 +00:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
2019-11-15 03:20:01 +00:00
|
|
|
)
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// InventoryItemWeapon stores the info of an weapon item in the inventory
|
2019-11-15 03:20:01 +00:00
|
|
|
type InventoryItemWeapon struct {
|
2020-06-13 22:32:09 +00: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"`
|
|
|
|
WeaponClass string `json:"weaponClass"`
|
|
|
|
WeaponClassOffHand string `json:"weaponClassOffHand"`
|
2019-11-15 03:20:01 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// GetWeaponClass returns the class of the weapon
|
2020-06-13 22:32:09 +00:00
|
|
|
func (v *InventoryItemWeapon) GetWeaponClass() string {
|
|
|
|
if v == nil || v.ItemCode == "" {
|
2019-11-15 03:20:01 +00:00
|
|
|
return "hth"
|
|
|
|
}
|
2020-06-30 21:04:41 +00:00
|
|
|
|
2020-06-13 22:32:09 +00:00
|
|
|
return v.WeaponClass
|
2019-11-15 03:20:01 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// GetWeaponClassOffHand returns the class of the off hand weapon
|
2020-06-13 22:32:09 +00:00
|
|
|
func (v *InventoryItemWeapon) GetWeaponClassOffHand() string {
|
|
|
|
if v == nil || v.ItemCode == "" {
|
2019-11-15 03:20:01 +00:00
|
|
|
return ""
|
|
|
|
}
|
2020-06-30 21:04:41 +00:00
|
|
|
|
2020-06-13 22:32:09 +00:00
|
|
|
return v.WeaponClassOffHand
|
2019-11-15 03:20:01 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// InventoryItemName returns the name of the weapon
|
2019-12-29 04:32:53 +00:00
|
|
|
func (v *InventoryItemWeapon) InventoryItemName() string {
|
|
|
|
if v == nil {
|
|
|
|
return ""
|
|
|
|
}
|
2020-06-30 21:04:41 +00:00
|
|
|
|
2020-06-13 22:32:09 +00:00
|
|
|
return v.ItemName
|
2019-11-15 03:20:01 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// InventoryItemType returns the item type of the weapon
|
2019-12-29 04:32:53 +00:00
|
|
|
func (v *InventoryItemWeapon) InventoryItemType() d2enum.InventoryItemType {
|
2019-11-15 03:20:01 +00:00
|
|
|
return d2enum.InventoryItemTypeWeapon
|
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// InventoryGridSize returns the grid size of the weapon
|
|
|
|
func (v *InventoryItemWeapon) InventoryGridSize() (sizeX, sizeY int) {
|
2020-06-13 22:32:09 +00:00
|
|
|
return v.InventorySizeX, v.InventorySizeY
|
2019-11-15 03:20:01 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// InventoryGridSlot returns the grid slot coordinates of the weapon
|
|
|
|
func (v *InventoryItemWeapon) InventoryGridSlot() (slotX, slotY int) {
|
2020-06-13 22:32:09 +00:00
|
|
|
return v.InventorySlotX, v.InventorySlotY
|
2019-12-29 04:32:53 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// SetInventoryGridSlot sets the InventorySlotX and InventorySlotY of the weapon with the given x and y values
|
|
|
|
func (v *InventoryItemWeapon) SetInventoryGridSlot(x, y int) {
|
2020-06-13 22:32:09 +00:00
|
|
|
v.InventorySlotX, v.InventorySlotY = x, y
|
2019-12-29 04:32:53 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// Serialize returns the weapon object as a byte array
|
2019-12-29 04:32:53 +00:00
|
|
|
func (v *InventoryItemWeapon) Serialize() []byte {
|
2019-11-15 03:20:01 +00:00
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
|
2020-06-30 21:04:41 +00:00
|
|
|
// GetItemCode returns the item code of the weapon
|
2020-06-13 22:32:09 +00:00
|
|
|
func (v *InventoryItemWeapon) GetItemCode() string {
|
2019-12-29 04:32:53 +00:00
|
|
|
if v == nil {
|
|
|
|
return ""
|
|
|
|
}
|
2020-06-30 21:04:41 +00:00
|
|
|
|
2020-06-13 22:32:09 +00:00
|
|
|
return v.ItemCode
|
2019-11-15 03:20:01 +00:00
|
|
|
}
|