core.components.item module

class core.components.item.Item(name=None, id=None)[source]

Bases: object

An item object is an item that can be used either in or out of combat.

Example:

>>> potion_item = Item("Potion")
>>> pprint.pprint(potion_item.__dict__)
{'description': u'Heals a monster by 50 HP.',
 'effect': [u'heal'],
 'id': 1,
 'name': u'Potion',
 'power': 50,
 'sprite': u'resources/gfx/items/potion.png',
 'surface': <Surface(66x90x32 SW)>,
 'surface_size_original': (66, 90),
 'type': u'Consumable'}
capture(user, target)[source]

Captures target monster.

Parameters:
  • user (Varies) – The monster or object that is using this item.
  • target (Varies) – The monster or object that we are using this item on.
Return type:

bool

Returns:

Success

heal(user, target)[source]

This effect heals the target based on the item’s power attribute.

Parameters:
  • user (Varies) – The monster or object that is using this item.
  • target (Varies) – The monster or object that we are using this item on.
Return type:

bool

Returns:

Success

Examples: >>> potion_item = Item(“Potion”) >>> potion_item.heal(bulbatux, game)

load(name, id)[source]

Loads and sets this items’s attributes from the item.db database. The item is looked up in the database by name or id.

Parameters:
  • name (String) – The name of the item to look up in the monster.item database.
  • id (Integer) – The id of the item to look up in the item.db database.
Return type:

None

Returns:

None

Examples:

>>> potion_item = Item()
>>> potion_item.load("Potion", None)    # Load an item by name.
>>> potion_item.load(None, 1)           # Load an item by id.
>>> pprint.pprint(potion_item.__dict__)
{'description': u'Heals a monster by 50 HP.',
 'effect': [u'heal'],
 'id': 1,
 'name': u'Potion',
 'power': 50,
 'type': u'Consumable'}
use(user, target)[source]

Applies this items’s effects as defined in the “effect” column of the item database. This method will execute a function with the same name as the effect defined in the database. If you want to add a new effect, simply create a new function under the Item class with the name of the effect you define in item.db.

Parameters:
  • user (Varies) – The monster or object that is using this item.
  • target (Varies) – The monster or object that we are using this item on.
Return type:

bool

Returns:

Success