tuxemon.technique.techeffect module

class tuxemon.technique.techeffect.TechEffect[source]

Bases: object

TechEffects are executed by techniques.

TechEffect subclasses implement “effects” defined in Tuxemon techniques. All subclasses, at minimum, must implement the following:

  • The TechEffect.apply() method

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

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

Parameters

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

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 Technique, the parameter’s value will be passed to the type constructor.

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

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

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

apply(tech, user, target)[source]
Parameters:
  • tech (Technique) –

  • user (Monster) –

  • target (Monster) –

Return type:

TechEffectResult

name: ClassVar[str]
session: Session
class tuxemon.technique.techeffect.TechEffectResult(*args, **kwargs)[source]

Bases: dict

success: bool