inventory

package
v0.0.0-...-54eea7a Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FillSlot

func FillSlot(inventorySlot *Slot, slot int, inv *Inventory, maxHP bool)

Types

type Inventory

type Inventory struct {
	Slots map[int]*Slot `json:"slots"`
	// contains filtered or unexported fields
}

func (*Inventory) AddItem

func (inv *Inventory) AddItem(item interface{}, itemType string, itemID, quantity, hp int, itemSize float32, maxHP int, newSlot bool, userID int) bool

func (*Inventory) AddItemFromSlot

func (inv *Inventory) AddItemFromSlot(slot *Slot, userID int) bool

func (*Inventory) FillInventory

func (inv *Inventory) FillInventory(rows *sql.Rows)

func (*Inventory) GetEmptySlot

func (inv *Inventory) GetEmptySlot() int

func (*Inventory) GetSize

func (inv *Inventory) GetSize() float32

func (*Inventory) RemoveItem

func (inv *Inventory) RemoveItem(itemID int, itemType string, quantityRemove int) error

func (*Inventory) RemoveItemsByOtherInventory

func (inv *Inventory) RemoveItemsByOtherInventory(inv2 *Inventory) bool

метод удаляем все итемы из inv которые есть в inv2 если они все в наличие

func (*Inventory) SearchItemsByOtherInventory

func (inv *Inventory) SearchItemsByOtherInventory(inv2 *Inventory) bool

метод смотрит все предметы inv2 что бы они были в inv на наличие

func (*Inventory) SetSlotsSize

func (inv *Inventory) SetSlotsSize(size int)

func (*Inventory) ViewItems

func (inv *Inventory) ViewItems(itemID int, itemType string, quantityFind int) bool

метод смотрим естли необходимое количество предметов в инвентаре

func (*Inventory) ViewItemsBySlots

func (inv *Inventory) ViewItemsBySlots(slots map[int]*Slot) bool

метод делает сравнение инвентарей слот к слоту

func (*Inventory) ViewQuantityItems

func (inv *Inventory) ViewQuantityItems(itemID int, itemType string) int

метод считает все итемы в инвентаре

type Slot

type Slot struct {
	Item       interface{} `json:"item"`
	Quantity   int         `json:"quantity"`
	Type       string      `json:"type"`
	ItemID     int         `json:"item_id"`
	InsertToDB bool        `json:"insert_to_db"`
	HP         int         `json:"hp"`
	MaxHP      int         `json:"max_hp"`
	Size       float32     `json:"size"`

	PlaceUserID int  `json:"place_user_id"`
	Tax         int  `json:"tax"`  // поле для налогов
	Find        bool `json:"find"` // поле для верстака, обозначающие естли такое количество итемов на складе или нет
}

func (*Slot) AddItemBySlot

func (slot *Slot) AddItemBySlot(quantity, userID int)

func (*Slot) RemoveItemBySlot

func (slot *Slot) RemoveItemBySlot(quantityRemove int) (CountRemove int)

когда slot.Item = nil он удалиться из бд при обновление данных

Jump to

Keyboard shortcuts

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