item

package
v0.0.0-...-ac9a988 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: GPL-2.0 Imports: 10 Imported by: 7

Documentation

Index

Constants

View Source
const (
	Head   = Slot("itSlotHead")
	Neck   = Slot("itSlotNeck")
	Chest  = Slot("itSlotChest")
	Hand   = Slot("itSlotHand")
	Finger = Slot("itSlotFinger")
	Legs   = Slot("itSlotLegs")
	Feet   = Slot("itSlotFeet")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Armor

type Armor struct {
	// contains filtered or unexported fields
}

Struct for armor items.

func NewArmor

func NewArmor(data res.ArmorData) *Armor

NewArmor creates new armor from specified armor data.

func (*Armor) Armor

func (a *Armor) Armor() int

Armor returns armor rating value.

func (*Armor) EquipEffects

func (a *Armor) EquipEffects() (effs []*effect.Effect)

EquipEffects returns armor equip effects

func (*Armor) EquipReqs

func (a *Armor) EquipReqs() []req.Requirement

EquipReqs returns armor equip requirements.

func (*Armor) ID

func (a *Armor) ID() string

ID returns armor ID.

func (*Armor) Level

func (a *Armor) Level() int

Level returns armor level.

func (*Armor) Serial

func (a *Armor) Serial() string

Serial returns armor serial value.

func (*Armor) SetSerial

func (a *Armor) SetSerial(s string)

SetSerial sets specified value as serial value of armor.

func (*Armor) Slots

func (a *Armor) Slots() []Slot

Slots returns types of slots occupated by this armor after equipping.

func (*Armor) Update

func (a *Armor) Update(delta int64)

Update updates item.

func (*Armor) UseAction

func (a *Armor) UseAction() *useaction.UseAction

UseAction returns use action.

func (*Armor) Value

func (a *Armor) Value() int

Value returns armor value.

type Container

type Container interface {
	serial.Serialer
	Inventory() *Inventory
}

Interface for objects with inventory.

type Equiper

type Equiper interface {
	ID() string
	Serial() string
	EquipReqs() []req.Requirement
	Slots() []Slot
}

Interface for 'equipable' items.

type Inventory

type Inventory struct {
	// contains filtered or unexported fields
}

Struct for container with items.

func NewInventory

func NewInventory() *Inventory

NewInventory creates new inventory.

func (*Inventory) AddItem

func (i *Inventory) AddItem(it Item)

AddItems add specified item to inventory. Item will be marked as tradeable and lootable inside the inventory. Trade value will be set as the same as item value.

func (*Inventory) Apply

func (i *Inventory) Apply(data res.InventoryData)

Apply applies specified data on the inventory.

func (*Inventory) Data

func (i *Inventory) Data() res.InventoryData

Data creates data resource for inventory.

func (*Inventory) Item

func (i *Inventory) Item(id, serial string) *InventoryItem

Item returns item with specified ID and serial from the inventory or nil if no such item was found.

func (*Inventory) Items

func (i *Inventory) Items() (items []*InventoryItem)

Items returns all items in inventory.

func (*Inventory) LootItem

func (i *Inventory) LootItem(id, serial string) Item

LootItem returns loot item.

func (*Inventory) RemoveItem

func (i *Inventory) RemoveItem(it Item)

RemoveItem removes specified item from inventory.

func (*Inventory) SetOnItemRemovedFunc

func (i *Inventory) SetOnItemRemovedFunc(f func(i Item))

SetOnItemRemoved sets function to trigger after removing item from the inventory.

func (*Inventory) Size

func (i *Inventory) Size() int

Size returns current amount of items in inventory.

func (*Inventory) Update

func (i *Inventory) Update(delta int64)

Update updates all items in the inventory.

type InventoryItem

type InventoryItem struct {
	Item
	Price int
	Trade bool
	Loot  bool
}

Struct for inventory items.

type Item

type Item interface {
	serial.Serialer
	Value() int
	Level() int
	UseAction() *useaction.UseAction
	Update(d int64)
}

Interface for items.

func New

func New(data res.ItemData) Item

New creates item from specified data. Returns nil if specified data is not a armor, weapon, or misc item data.

type Misc

type Misc struct {
	// contains filtered or unexported fields
}

Struct for miscellaneous items.

func NewMisc

func NewMisc(data res.MiscItemData) *Misc

NewMisc creates new misc item.

func (*Misc) Consumable

func (m *Misc) Consumable() bool

Consumable checks if item should be deleted after use.

func (*Misc) Currency

func (m *Misc) Currency() bool

Currency check if item can be used as currency.

func (*Misc) ID

func (m *Misc) ID() string

ID returns item ID.

func (*Misc) Level

func (m *Misc) Level() int

Level return item level.

func (*Misc) Serial

func (m *Misc) Serial() string

Serial returns item serial value.

func (*Misc) SetSerial

func (m *Misc) SetSerial(s string)

SetSerial sets item serial value.

func (*Misc) Update

func (m *Misc) Update(delta int64)

Update updates item.

func (*Misc) UseAction

func (m *Misc) UseAction() *useaction.UseAction

UseAction returns items use action.

func (*Misc) Value

func (m *Misc) Value() int

Value return item value.

type Slot

type Slot string

Type for slot type occupated by item.

type Weapon

type Weapon struct {
	// contains filtered or unexported fields
}

Struct for weapons.

func NewWeapon

func NewWeapon(data res.WeaponData) *Weapon

NewWeapon creates new weapon with specified parameters.

func (*Weapon) Damage

func (w *Weapon) Damage() (int, int)

Damge returns minimal and maximal damge values.

func (*Weapon) DamageEffects

func (w *Weapon) DamageEffects() []res.EffectData

DamageEffects returns weapon hit effects.

func (*Weapon) DamageType

func (w *Weapon) DamageType() objects.Element

DamageType retruns weapon damage type.

func (*Weapon) EquipReqs

func (w *Weapon) EquipReqs() []req.Requirement

EquipReqs returns weapon equip requirements.

func (*Weapon) ID

func (w *Weapon) ID() string

ID returns weapon ID.

func (*Weapon) Level

func (w *Weapon) Level() int

Level returns item level.

func (*Weapon) Serial

func (w *Weapon) Serial() string

Serial returns weapon serial value.

func (*Weapon) SetSerial

func (w *Weapon) SetSerial(s string)

SetSerial sets specified value as serial value of weapon.

func (*Weapon) Slots

func (w *Weapon) Slots() []Slot

Slots returns type of slots occupated by this weapon after equipping.

func (*Weapon) Update

func (w *Weapon) Update(delta int64)

Update updates item.

func (*Weapon) UseAction

func (w *Weapon) UseAction() *useaction.UseAction

UseAction returns use action.

func (*Weapon) Value

func (w *Weapon) Value() int

Value returns item value.

Jump to

Keyboard shortcuts

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