Documentation ¶
Index ¶
- Variables
- type AbilityString
- type InventoryHandler
- func (ih *InventoryHandler) AddAbility(abilityName string, chargeOpt ...int) (AbilityString, error)
- func (ih *InventoryHandler) AddAnyAbility(abilityName string, chargeOpt ...int) (AbilityString, error)
- func (ih *InventoryHandler) AddCoinBonus(decStr string) error
- func (ih *InventoryHandler) AddCoins(amount int64) error
- func (ih *InventoryHandler) AddEffect(effect string) (string, error)
- func (ih *InventoryHandler) AddImmunity(immunity string) (string, error)
- func (ih *InventoryHandler) AddItem(name string) (string, error)
- func (ih *InventoryHandler) AddLimit(limit int) error
- func (ih *InventoryHandler) AddLuck(amount int64) error
- func (ih *InventoryHandler) AddNote(note string) error
- func (ih *InventoryHandler) AddPerk(perk string) (string, error)
- func (ih *InventoryHandler) AddStatus(name string) (string, error)
- func (ih *InventoryHandler) CalculateAllianceLuck(memberIDs []string) (int64, error)
- func (ih *InventoryHandler) CreateInventory(initInv *data.Inventory) error
- func (ih *InventoryHandler) GetInventory() *data.Inventory
- func (ih *InventoryHandler) RefreshInventory() error
- func (ih *InventoryHandler) RemoveAbility(abilityName string) (string, error)
- func (ih *InventoryHandler) RemoveAnyAbility(aaName string) (string, error)
- func (ih *InventoryHandler) RemoveCoinBonus(decStr string) error
- func (ih *InventoryHandler) RemoveCoins(amount int64) error
- func (ih *InventoryHandler) RemoveEffect(effect string) (string, error)
- func (ih *InventoryHandler) RemoveImmunity(immunity string) (string, error)
- func (ih *InventoryHandler) RemoveItem(item string) (string, error)
- func (ih *InventoryHandler) RemoveLimit(limit int) error
- func (ih *InventoryHandler) RemoveLuck(amount int64) error
- func (ih *InventoryHandler) RemoveNote(index int) error
- func (ih *InventoryHandler) RemovePerk(perk string) (string, error)
- func (ih *InventoryHandler) RemoveStatus(name string) (string, error)
- func (ih *InventoryHandler) SetAbilityCharges(abilityName string, charge int) error
- func (ih *InventoryHandler) SetAlignment(alignment string) error
- func (ih *InventoryHandler) SetAnyAbilityCharges(aaName string, charge int) error
- func (ih *InventoryHandler) SetCoinBonus(decStr string) error
- func (ih *InventoryHandler) SetCoins(amount int64) error
- func (ih *InventoryHandler) SetLimit(limit int) error
- func (ih *InventoryHandler) SetLuck(size int64) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrAnyAbilityNotFound = errors.New("ability not found") ErrAnyAbilityAlreadyExists = errors.New("ability already exists") )
var ( ErrInsufficientCoins = fmt.Errorf("insufficient coins") ErrInsufficientBonus = fmt.Errorf("insufficient bonus") ErrInvalidDecimalString = fmt.Errorf("invalid decimal string, unable to convert to decimal value") )
var ( ErrEffectAlreadyExists = errors.New("effect already exists") ErrEffectNotFound = errors.New("effect not found") )
var ( ErrImmunityExists = errors.New("immunity already exists") ErrImmunityNotFound = errors.New("immunity not found") )
var ( ErrPerkAlreadyExists = errors.New("perk already exists") ErrPerkNotFound = errors.New("perk not found") )
var ( ErrStatusAlreadyExists = errors.New("status already exists") ErrStatusNotFound = errors.New("status not found") )
var ErrAbilityNotFound = errors.New("ability not found")
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) 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) 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