2019-11-14 22:20:01 -05:00
|
|
|
package d2core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2019-11-17 00:16:33 -05:00
|
|
|
"github.com/OpenDiablo2/D2Shared/d2common/d2enum"
|
|
|
|
"github.com/OpenDiablo2/D2Shared/d2data/d2datadict"
|
2019-11-14 22:20:01 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type InventoryItemWeapon struct {
|
|
|
|
inventorySizeX int
|
|
|
|
inventorySizeY int
|
2019-12-28 23:32:53 -05:00
|
|
|
inventorySlotX int
|
|
|
|
inventorySlotY int
|
2019-11-14 22:20:01 -05:00
|
|
|
itemName string
|
|
|
|
itemCode string
|
|
|
|
weaponClass string
|
|
|
|
weaponClassOffHand string
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func GetWeaponItemByCode(code string) *InventoryItemWeapon {
|
2019-11-14 22:20:01 -05:00
|
|
|
// TODO: Non-normal codes will fail here...
|
|
|
|
result := d2datadict.Weapons[code]
|
|
|
|
if result == nil {
|
|
|
|
log.Fatalf("Could not find weapon entry for code '%s'", code)
|
|
|
|
}
|
2019-12-28 23:32:53 -05:00
|
|
|
return &InventoryItemWeapon{
|
2019-11-14 22:20:01 -05:00
|
|
|
inventorySizeX: result.InventoryWidth,
|
|
|
|
inventorySizeY: result.InventoryHeight,
|
|
|
|
itemName: result.Name,
|
|
|
|
itemCode: result.Code,
|
|
|
|
weaponClass: result.WeaponClass,
|
|
|
|
weaponClassOffHand: result.WeaponClass2Hand,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemWeapon) WeaponClass() string {
|
|
|
|
if v == nil || v.itemCode == "" {
|
2019-11-14 22:20:01 -05:00
|
|
|
return "hth"
|
|
|
|
}
|
|
|
|
return v.weaponClass
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemWeapon) WeaponClassOffHand() string {
|
|
|
|
if v == nil || v.itemCode == "" {
|
2019-11-14 22:20:01 -05:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return v.weaponClassOffHand
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemWeapon) InventoryItemName() string {
|
|
|
|
if v == nil {
|
|
|
|
return ""
|
|
|
|
}
|
2019-11-14 22:20:01 -05:00
|
|
|
return v.itemName
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemWeapon) InventoryItemType() d2enum.InventoryItemType {
|
2019-11-14 22:20:01 -05:00
|
|
|
return d2enum.InventoryItemTypeWeapon
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemWeapon) InventoryGridSize() (int, int) {
|
2019-11-14 22:20:01 -05:00
|
|
|
return v.inventorySizeX, v.inventorySizeY
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemWeapon) InventoryGridSlot() (int, int) {
|
|
|
|
return v.inventorySlotX, v.inventorySlotY
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *InventoryItemWeapon) SetInventoryGridSlot(x int, y int) {
|
|
|
|
v.inventorySlotX, v.inventorySlotY = x, y
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *InventoryItemWeapon) Serialize() []byte {
|
2019-11-14 22:20:01 -05:00
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
|
2019-12-28 23:32:53 -05:00
|
|
|
func (v *InventoryItemWeapon) ItemCode() string {
|
|
|
|
if v == nil {
|
|
|
|
return ""
|
|
|
|
}
|
2019-11-14 22:20:01 -05:00
|
|
|
return v.itemCode
|
|
|
|
}
|