inventory

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAnyAbilityNotFound      = errors.New("ability not found")
	ErrAnyAbilityAlreadyExists = errors.New("ability already exists")
)
View Source
var (
	ErrInsufficientCoins    = fmt.Errorf("insufficient coins")
	ErrInsufficientBonus    = fmt.Errorf("insufficient bonus")
	ErrInvalidDecimalString = fmt.Errorf("invalid decimal string, unable to convert to decimal value")
)
View Source
var (
	ErrEffectAlreadyExists = errors.New("effect already exists")
	ErrEffectNotFound      = errors.New("effect not found")
)
View Source
var (
	ErrImmunityExists   = errors.New("immunity already exists")
	ErrImmunityNotFound = errors.New("immunity not found")
)
View Source
var (
	ErrPerkAlreadyExists = errors.New("perk already exists")
	ErrPerkNotFound      = errors.New("perk not found")
)
View Source
var (
	ErrStatusAlreadyExists = errors.New("status already exists")
	ErrStatusNotFound      = errors.New("status not found")
)
View Source
var ErrAbilityNotFound = errors.New("ability not found")
View Source
var ErrItemNotFound = errors.New("item not found")

Functions

This section is empty.

Types

type AbilityString

type AbilityString string

InventoryAbility is a type alias for the name of an ability Follows the format of "Ability Name [Charges]"

func NewAbilityStringFromAA

func NewAbilityStringFromAA(ab *data.AnyAbility, chargeOpt ...int) *AbilityString

Build Inventory Item from Ability

func NewAbilityStringFromAbility

func NewAbilityStringFromAbility(ab *data.Ability, chargeOpt ...int) *AbilityString

func (*AbilityString) GetCharges

func (as *AbilityString) GetCharges() int

func (*AbilityString) GetName

func (as *AbilityString) GetName() string

func (*AbilityString) SetCharges

func (aas *AbilityString) SetCharges(charge int) AbilityString

Returns a new InventoryAbility with the given charge

func (*AbilityString) SetName

func (as *AbilityString) SetName(name string) AbilityString

Returns a new InventoryAbility with the given name

type InventoryHandler

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

Handles all inventory related actions

func InitInventoryHandler

func InitInventoryHandler(models data.Models, inv ...*data.Inventory) *InventoryHandler

Create a new InventoryHandler whthout an Inventory (normally used for creating a new inventory)

func (*InventoryHandler) AddAbility

func (ih *InventoryHandler) AddAbility(abilityName string, chargeOpt ...int) (AbilityString, error)

func (*InventoryHandler) AddAnyAbility

func (ih *InventoryHandler) AddAnyAbility(abilityName string, chargeOpt ...int) (AbilityString, error)

Will insert or update a given any ability for an inventory. Will default charge to 1 if not provided.

func (*InventoryHandler) AddCoinBonus

func (ih *InventoryHandler) AddCoinBonus(decStr string) error

func (*InventoryHandler) AddCoins

func (ih *InventoryHandler) AddCoins(amount int64) error

func (*InventoryHandler) AddEffect

func (ih *InventoryHandler) AddEffect(effect string) (string, error)

func (*InventoryHandler) AddImmunity

func (ih *InventoryHandler) AddImmunity(immunity string) (string, error)

Add an immunity to inventory and persist to database, if it doesn't already exist

func (*InventoryHandler) AddItem

func (ih *InventoryHandler) AddItem(name string) (string, error)

func (*InventoryHandler) AddLimit

func (ih *InventoryHandler) AddLimit(limit int) error

func (*InventoryHandler) AddLuck

func (ih *InventoryHandler) AddLuck(amount int64) error

func (*InventoryHandler) AddNote

func (ih *InventoryHandler) AddNote(note string) error

func (*InventoryHandler) AddPerk

func (ih *InventoryHandler) AddPerk(perk string) (string, error)

func (*InventoryHandler) AddStatus

func (ih *InventoryHandler) AddStatus(name string) (string, error)

func (*InventoryHandler) CalculateAllianceLuck

func (ih *InventoryHandler) CalculateAllianceLuck(memberIDs []string) (int64, error)

Determines the luck a player will get from their alliance. Good and Evil get +2 per each other member in the same alliance, and +1 for neutral.

func (*InventoryHandler) CreateInventory

func (ih *InventoryHandler) CreateInventory(initInv *data.Inventory) error

func (*InventoryHandler) GetInventory

func (ih *InventoryHandler) GetInventory() *data.Inventory

func (*InventoryHandler) RefreshInventory

func (ih *InventoryHandler) RefreshInventory() error

func (*InventoryHandler) RemoveAbility

func (ih *InventoryHandler) RemoveAbility(abilityName string) (string, error)

func (*InventoryHandler) RemoveAnyAbility

func (ih *InventoryHandler) RemoveAnyAbility(aaName string) (string, error)

func (*InventoryHandler) RemoveCoinBonus

func (ih *InventoryHandler) RemoveCoinBonus(decStr string) error

func (*InventoryHandler) RemoveCoins

func (ih *InventoryHandler) RemoveCoins(amount int64) error

Will error if the total amount of coins is less than the amount to remove

func (*InventoryHandler) RemoveEffect

func (ih *InventoryHandler) RemoveEffect(effect string) (string, error)

func (*InventoryHandler) RemoveImmunity

func (ih *InventoryHandler) RemoveImmunity(immunity string) (string, error)

Remove an immunity from inventory and persist to database

func (*InventoryHandler) RemoveItem

func (ih *InventoryHandler) RemoveItem(item string) (string, error)

func (*InventoryHandler) RemoveLimit

func (ih *InventoryHandler) RemoveLimit(limit int) error

func (*InventoryHandler) RemoveLuck

func (ih *InventoryHandler) RemoveLuck(amount int64) error

func (*InventoryHandler) RemoveNote

func (ih *InventoryHandler) RemoveNote(index int) error

func (*InventoryHandler) RemovePerk

func (ih *InventoryHandler) RemovePerk(perk string) (string, error)

func (*InventoryHandler) RemoveStatus

func (ih *InventoryHandler) RemoveStatus(name string) (string, error)

func (*InventoryHandler) SetAbilityCharges

func (ih *InventoryHandler) SetAbilityCharges(abilityName string, charge int) error

func (*InventoryHandler) SetAlignment

func (ih *InventoryHandler) SetAlignment(alignment string) error

func (*InventoryHandler) SetAnyAbilityCharges

func (ih *InventoryHandler) SetAnyAbilityCharges(aaName string, charge int) error

func (*InventoryHandler) SetCoinBonus

func (ih *InventoryHandler) SetCoinBonus(decStr string) error

func (*InventoryHandler) SetCoins

func (ih *InventoryHandler) SetCoins(amount int64) error

func (*InventoryHandler) SetLimit

func (ih *InventoryHandler) SetLimit(limit int) error

func (*InventoryHandler) SetLuck

func (ih *InventoryHandler) SetLuck(size int64) error

Jump to

Keyboard shortcuts

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