d2inventory

package
v0.0.0-...-7f92c57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package d2inventory provides representations of player inventory

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CharacterEquipment

type CharacterEquipment struct {
	Head      *InventoryItemArmor  `json:"head"`      // Head
	Torso     *InventoryItemArmor  `json:"torso"`     // TR
	Legs      *InventoryItemArmor  `json:"legs"`      // Legs
	RightArm  *InventoryItemArmor  `json:"rightArm"`  // RA
	LeftArm   *InventoryItemArmor  `json:"leftArm"`   // LA
	LeftHand  *InventoryItemWeapon `json:"leftHand"`  // LH
	RightHand *InventoryItemWeapon `json:"rightHand"` // RH
	Shield    *InventoryItemArmor  `json:"shield"`    // SH

}

CharacterEquipment stores equipments of a character

type HeroObjects

type HeroObjects map[d2enum.Hero]CharacterEquipment

HeroObjects map contains the hero type to CharacterEquipments

type InventoryItem

type InventoryItem interface {
	// GetInventoryItemName returns the name of this inventory item
	GetInventoryItemName() string
	// GetInventoryItemType returns the type of item this is
	GetInventoryItemType() d2enum.InventoryItemType
	// GetInventoryGridSize returns the width/height grid size of this inventory item
	GetInventoryGridSize() (int, int)
	// Returns the item code
	GetItemCode() string
	// Serializes the object for transport
	Serialize() []byte
}

InventoryItem defines the functionality of an inventory item

type InventoryItemArmor

type InventoryItemArmor struct {
	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"`
}

InventoryItemArmor stores the info of an armor item in the inventory

func (*InventoryItemArmor) GetArmorClass

func (v *InventoryItemArmor) GetArmorClass() string

GetArmorClass returns the class of the armor

func (*InventoryItemArmor) GetItemCode

func (v *InventoryItemArmor) GetItemCode() string

GetItemCode returns the item code of the armor

func (*InventoryItemArmor) InventoryGridSize

func (v *InventoryItemArmor) InventoryGridSize() (sizeX, sizeY int)

InventoryGridSize returns the grid size of the armor

func (*InventoryItemArmor) InventoryGridSlot

func (v *InventoryItemArmor) InventoryGridSlot() (slotX, slotY int)

InventoryGridSlot returns the grid slot coordinates of the armor

func (*InventoryItemArmor) InventoryItemName

func (v *InventoryItemArmor) InventoryItemName() string

InventoryItemName returns the name of the armor

func (*InventoryItemArmor) InventoryItemType

func (v *InventoryItemArmor) InventoryItemType() d2enum.InventoryItemType

InventoryItemType returns the item type of the armor

func (*InventoryItemArmor) Serialize

func (v *InventoryItemArmor) Serialize() []byte

Serialize returns the armor object as a byte array

func (*InventoryItemArmor) SetInventoryGridSlot

func (v *InventoryItemArmor) SetInventoryGridSlot(x, y int)

SetInventoryGridSlot sets the InventorySlotX and InventorySlotY of the armor with the given x and y values

type InventoryItemFactory

type InventoryItemFactory struct {
	DefaultHeroItems HeroObjects
	// contains filtered or unexported fields
}

InventoryItemFactory is responsible for creating inventory items

func NewInventoryItemFactory

func NewInventoryItemFactory(asset *d2asset.AssetManager) (*InventoryItemFactory, error)

NewInventoryItemFactory creates a new InventoryItemFactory and initializes it

func (*InventoryItemFactory) GetArmorItemByCode

func (f *InventoryItemFactory) GetArmorItemByCode(code string) (*InventoryItemArmor, error)

GetArmorItemByCode returns the armor item for the given code

func (*InventoryItemFactory) GetMiscItemByCode

func (f *InventoryItemFactory) GetMiscItemByCode(code string) (*InventoryItemMisc, error)

GetMiscItemByCode returns the miscellaneous item for the given code

func (*InventoryItemFactory) GetWeaponItemByCode

func (f *InventoryItemFactory) GetWeaponItemByCode(code string) (*InventoryItemWeapon, error)

GetWeaponItemByCode returns the weapon item for the given code

type InventoryItemMisc

type InventoryItemMisc struct {
	InventorySizeX int    `json:"inventorySizeX"`
	InventorySizeY int    `json:"inventorySizeY"`
	InventorySlotX int    `json:"inventorySlotX"`
	InventorySlotY int    `json:"inventorySlotY"`
	ItemName       string `json:"itemName"`
	ItemCode       string `json:"itemCode"`
}

InventoryItemMisc stores the info of an miscellaneous item in the inventory

func (*InventoryItemMisc) GetItemCode

func (v *InventoryItemMisc) GetItemCode() string

GetItemCode returns the item code of the miscellaneous item

func (*InventoryItemMisc) InventoryGridSize

func (v *InventoryItemMisc) InventoryGridSize() (sizeX, sizeY int)

InventoryGridSize returns the grid size of the miscellaneous item

func (*InventoryItemMisc) InventoryGridSlot

func (v *InventoryItemMisc) InventoryGridSlot() (slotX, slotY int)

InventoryGridSlot returns the grid slot coordinates of the miscellaneous item

func (*InventoryItemMisc) InventoryItemName

func (v *InventoryItemMisc) InventoryItemName() string

InventoryItemName returns the name of the miscellaneous item

func (*InventoryItemMisc) InventoryItemType

func (v *InventoryItemMisc) InventoryItemType() d2enum.InventoryItemType

InventoryItemType returns the item type of the miscellaneous item

func (*InventoryItemMisc) Serialize

func (v *InventoryItemMisc) Serialize() []byte

Serialize returns the miscellaneous item object as a byte array

func (*InventoryItemMisc) SetInventoryGridSlot

func (v *InventoryItemMisc) SetInventoryGridSlot(x, y int)

SetInventoryGridSlot sets the InventorySlotX and InventorySlotY of the miscellaneous item with the given x and y values

type InventoryItemWeapon

type InventoryItemWeapon struct {
	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"`
}

InventoryItemWeapon stores the info of an weapon item in the inventory

func (*InventoryItemWeapon) GetItemCode

func (v *InventoryItemWeapon) GetItemCode() string

GetItemCode returns the item code of the weapon

func (*InventoryItemWeapon) GetWeaponClass

func (v *InventoryItemWeapon) GetWeaponClass() string

GetWeaponClass returns the class of the weapon

func (*InventoryItemWeapon) GetWeaponClassOffHand

func (v *InventoryItemWeapon) GetWeaponClassOffHand() string

GetWeaponClassOffHand returns the class of the off hand weapon

func (*InventoryItemWeapon) InventoryGridSize

func (v *InventoryItemWeapon) InventoryGridSize() (sizeX, sizeY int)

InventoryGridSize returns the grid size of the weapon

func (*InventoryItemWeapon) InventoryGridSlot

func (v *InventoryItemWeapon) InventoryGridSlot() (slotX, slotY int)

InventoryGridSlot returns the grid slot coordinates of the weapon

func (*InventoryItemWeapon) InventoryItemName

func (v *InventoryItemWeapon) InventoryItemName() string

InventoryItemName returns the name of the weapon

func (*InventoryItemWeapon) InventoryItemType

func (v *InventoryItemWeapon) InventoryItemType() d2enum.InventoryItemType

InventoryItemType returns the item type of the weapon

func (*InventoryItemWeapon) Serialize

func (v *InventoryItemWeapon) Serialize() []byte

Serialize returns the weapon object as a byte array

func (*InventoryItemWeapon) SetInventoryGridSlot

func (v *InventoryItemWeapon) SetInventoryGridSlot(x, y int)

SetInventoryGridSlot sets the InventorySlotX and InventorySlotY of the weapon with the given x and y values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL