1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-10-31 16:27:18 -04:00
OpenDiablo2/d2core/inventory_item_weapon.go

84 lines
1.9 KiB
Go
Raw Normal View History

2019-11-14 22:20:01 -05:00
package d2core
import (
"log"
"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
inventorySlotX int
inventorySlotY int
2019-11-14 22:20:01 -05:00
itemName string
itemCode string
weaponClass string
weaponClassOffHand string
}
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)
}
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,
}
}
func (v *InventoryItemWeapon) WeaponClass() string {
if v == nil || v.itemCode == "" {
2019-11-14 22:20:01 -05:00
return "hth"
}
return v.weaponClass
}
func (v *InventoryItemWeapon) WeaponClassOffHand() string {
if v == nil || v.itemCode == "" {
2019-11-14 22:20:01 -05:00
return ""
}
return v.weaponClassOffHand
}
func (v *InventoryItemWeapon) InventoryItemName() string {
if v == nil {
return ""
}
2019-11-14 22:20:01 -05:00
return v.itemName
}
func (v *InventoryItemWeapon) InventoryItemType() d2enum.InventoryItemType {
2019-11-14 22:20:01 -05:00
return d2enum.InventoryItemTypeWeapon
}
func (v *InventoryItemWeapon) InventoryGridSize() (int, int) {
2019-11-14 22:20:01 -05:00
return v.inventorySizeX, v.inventorySizeY
}
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{}
}
func (v *InventoryItemWeapon) ItemCode() string {
if v == nil {
return ""
}
2019-11-14 22:20:01 -05:00
return v.itemCode
}