tuxemon.item.itemcondition module

class tuxemon.item.itemcondition.ItemCondition[source]

Bases: object

ItemConditions are evaluated by items.

ItemCondition subclasses implement “conditions” defined in Tuxemon items. All subclasses, at minimum, must implement the following:

  • The ItemCondition.test() method

  • A meaningful name, which must match the name in item file effects

By populating the “valid_parameters” class attribute, subclasses will be assigned a “parameters” instance attribute that holds the parameters passed to the condition in the item file. It is also used to check the syntax of conditions, by verifying the correct type and number of parameters passed.

Parameters

Tuxemon supports type-checking of the parameters defined in the items.

valid_parameters may be the following format (may change):

(type, name)

  • the type may be any valid python type, or even a python class or function

  • type may be a single type, or a tuple of types

  • type, if a tuple, may include None to indicate the parameter is optional

  • name must be a valid python string

After parsing the parameters of the Item, the parameter’s value will be passed to the type constructor.

Example types: str, int, float, Monster, NPC

(int, “level”) => level must be an int ((int, float), “level”) => can be an int or float ((int, float, None), “level”) => is optional

(Monster, “monster_slug”) => a Monster instance will be created

name: ClassVar[str]
session: Session
test(target)[source]

Return True if satisfied, or False if not.

Parameters:

target (Monster) – The target of the item’s use.

Return type:

bool