Items

class pyzork.equipment.Weapon(**kwargs)[source]
classmethod add_buff(**kwargs)

Decorator function to allow the user to define a buff by decorating a function. Takes the same parameters as the class. Since this specifically adds a buff, the stat_type parameter is required

classmethod add_effect(**kwargs)

Decorator function to allow the user to define an effect by decorating a function. Takes the same parameters as the class.

buff(entity)

Abstract method that must be implemented by every piece of equipment, this is the method used when calculating damage that dictates the various modifiers and buffs gotten

effect(target)

Abstract class that applies an effect when attacking

class pyzork.equipment.Armor(**kwargs)[source]
classmethod add_buff(**kwargs)

Decorator function to allow the user to define a buff by decorating a function. Takes the same parameters as the class. Since this specifically adds a buff, the stat_type parameter is required

classmethod add_effect(**kwargs)

Decorator function to allow the user to define an effect by decorating a function. Takes the same parameters as the class.

buff(entity)

Abstract method that must be implemented by every piece of equipment, this is the method used when calculating damage that dictates the various modifiers and buffs gotten

effect(target)

Abstract class that applies an effect when attacking

class pyzork.equipment.Consumable(**kwargs)[source]

Consumable are items which the entity can use at pretty much anytime to gain an effect, kinda like an ability with limited uses which costs no energy. Each consumable can be used a certain number of times before it disappears, if the entity buys more of the consumable then the charges will be added together. When selling a consumable the charges will be split up based on how many charges the buyer accepts, for example if the shop takes consumables with 2 charges and you have one with 5 then it will make two sales and discrd the remainer.

Parameters:
  • name (str) – The name of the item, if it is not provided then defaults first to the class docs and then the class name
  • description (Optional[str]) – The description of the item
  • charges (int) – The amount of times this item can be used
name

Name of the item

Type:str
description

Description of the item

Type:str
charges

The amount of times this item can be used

Type:int
classmethod add(**kwargs)[source]

Decorator method to create a consumable off a method, takes the same parameters as the class.

effect(target)[source]

The function called when the item is used, overwrite this to cause an effect

Parameters:target (Entity) – The target of the item, can be the user or could be an NPC
class pyzork.equipment.QuestItem(**kwargs)[source]

Quest items are special item which do nothing on their own but can be used as requirement for certain part of the story, for example the guards at the palace entrance won’t let you enter unless you have a letter of recommendation in your inventory.

Parameters:
  • name (str) – The name of the item, if it is not provided then defaults first to the class docs and then the class name
  • description (Optional[str]) – The description of the item
name

Name of the item

Type:str
description

Description of the item

Type:str
class pyzork.equipment.ShopItem(**kwargs)[source]

A shop item is an item that can be sold or bought in a shop.

Parameters:
  • item (Union[Consumable, QuestItem, Equipment]) – The item to sell, this is the class itself, not an instance of the object
  • price (int) – The price of the item
  • amount (int) – The number of items that are available for sale, if a entity sells an item it will increment the amount
item

The item being sold or bought

Type:Union[Consumable, QuestItem, Equipment]
price

The price at which it is being sold

Type:int
amount

How many more times the item can be sold

Type:int
name

The name of the item being sold

Type:int
description

The description of the item being sold

buy(entity: Entity)[source]

Buy an instance of that item

Parameters:entity (Entity) – The entity purchasing the item
sell(entity: Entity, resell: float)[source]

Sell an instance of that item

Parameters:
  • entity (Entity) – The entity selling the item
  • resell (float) – The resale value, this is usually passed down from the shop instance
class pyzork.equipment.Inventory(**kwargs)[source]

Inventories store all items: Equipment, Consumables and QuestItem.

Parameters:
  • items (List[Union[Consumable, Equipment, QuestItem]]) – A list of items this inventory starts with
  • weapon (Weapon) – The weapon this inventory comes equipped with by default
  • armor (Armor) – The armor this inventory comes equipped with by default
add_item(item: pyzork.equipment.Item)[source]

Add an item to the entity’s inventory

Parameters:item (Item) – The item you want to add to the inventory, the method will sort out where it needs to go.
equip_item(item: pyzork.equipment.Equipment)[source]

Equip either a weapon or armor

Parameters:item (Equipment) – The piece of equipment to add
get_consumable(**kwargs)[source]

Get an consumable instance based on a parameter. The parameter is any kwarg to you pass, if you want the parameter to be the name of the item then you can do something like get_consumable(name=’Health Potion’)

get_equipment(**kwargs)[source]

Get an equipment instance based on a parameter. The parameter is any kwarg to you pass, if you want the parameter to be the name of the item then you can do something like get_equipment(name=’Big Sword’)

get_item(**kwargs)[source]

Get an equipment, consumable or quest instance based on a parameter. The parameter is any kwarg to you pass, if you want the parameter to be the name of the item then you can do something like get_item(name=’Big Sword’)

get_quest(**kwargs)[source]

Get an quest instance based on a parameter. The parameter is any kwarg to you pass, if you want the parameter to be the name of the item then you can do something like get_quest(name=’Old Key’)

print()[source]

Print all the item in the entity’s inventory

print_consumables()[source]

Print all the consumables

print_equipment()[source]

Print all the equipments

print_quest()[source]

Print all the quest items

remove_item(item: pyzork.equipment.Item)[source]

Remove an item from the inventory

Parameters:item (Item) – The item to remove
use_item(item: pyzork.equipment.Consumable, target)[source]

Use a consumable on a target

Parameters:
  • item (Consumable) – The item to use
  • target (Entity) – The entity to use it on

Examples