pymasep.common.initializer

Submodules

Classes

Initializer

Initializer used to initialize the value of BaseObject.

InitializerCharacInterface

Initializer used to initialize a Characteristic from the interface.

InitializerCharacInterfaceShared

Initializer to choose Characteristic with VALUE_MODE_CHOICE shared among multiple interface.

InitializerContainer

Initializer used to initialize a Container

InitializerContainerInterface

Initializer used to initialize a Container by the interface

InitializerFixed

Initialize Characteristic with fixed value

InitializerObject

Initializer used to initialize an Object.

InitializerObjectInterface

Initializer used to initialize an Object from the interface.

InitializerObjectState

Initializer used to initialize an ObjectState.

InitializerObjectStateInterface

Initializer used to initialize an ObjectState from the interface.

Package Contents

class pymasep.common.initializer.Initializer(game, initializer_dict)

Initializer used to initialize the value of BaseObject. An initializer can be executed by the Engine (by default) or processed by the Interface.

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • value_type: for Characteristic, the type of the value (as string)

  • subclass_initializer: name of sub initializer used to initialize sub BaseObject. These initializers must already exist in the game

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

INIT_TYPE_ENGINE = 'Engine'

Initializer by the Engine

INIT_TYPE_INTERFACE = 'Interface'

Initializer by the Interface

game
name

name of the initializer used as id

value_type

type of the value (as string) for Characteristic

subclass_initializer

name of sub initializers used to initialize sub BaseObject

init_type

initializer by engine by default

apply(base_object)

Apply the initializer.

Parameters:

base_object – The BaseObject to initialize

Return type:

None

class pymasep.common.initializer.InitializerCharacInterface(game, initializer_dict)

Bases: pymasep.common.initializer.initializer.Initializer

Initializer used to initialize a Characteristic from the interface.

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • value_type: for Characteristic, the type of the value (as string)

  • subclass_initializer: name of sub initializer used to initialize sub BaseObject. These initializers must already exist in the game

  • value_mode: mode of the interface initialization : VALUE_MODE_*

  • param: for VALUE_MODE_DICE, string representing the dices and VALUE_MODE_CHOICE, list of tuples (description, value)

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

VALUE_MODE_VALUE = 'value'

Value is chosen in the interface

VALUE_MODE_DICE = 'dice'

value is chosen by a dice interface

VALUE_MODE_CHOICE = 'choice'

value is chosen in the interface among some choices

value_mode

Way of choosing the initializer value. see VALUE_MODE_*

param

parameter depending of initializer type

init_type

initializer by interface

class pymasep.common.initializer.InitializerCharacInterfaceShared(game, initializer_dict)

Bases: pymasep.common.initializer.initializer_charac_interface.InitializerCharacInterface

Initializer to choose Characteristic with VALUE_MODE_CHOICE shared among multiple interface.

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

filter_choice(charac_name, state)

Filter choices when an interface chose a value, all others must remove this choice.

Parameters:
  • charac_name (str) – Characteristic name used to filter other characteristics

  • state – state where the characteristic is stored

Returns:

the new list of choices filtered removing the value of

Return type:

List[Tuple[str, str]]

class pymasep.common.initializer.InitializerContainer(game, initializer_dict)

Bases: pymasep.common.initializer.initializer.Initializer

Initializer used to initialize a Container An initializer can be executed by the Engine (by default) or processed by the Interface.

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • type: type of initialization. ALL: all the objects in obj_init will be created. BUY: the player must choose the objects to buy

  • obj_init : dictionary containing the name of the objects that could be created/bought as the keys. Values are dictionaries with three keys: “cost”, the cost of the object, ‘template’: the template to create the object and ‘initializer’ used to initialize the object.

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

type

type of the initializer

obj_init

object creation and initialization

apply(base_object)

Apply the initializer.

Parameters:

base_object – The Container to initialize with all objects in the initializer

Return type:

None

apply_with_params(base_object, list_obj_to_create)

Create objects in the container and set the container state as ‘run’

Parameters:
  • base_object – The Container to initialize with list_obj_to_create objects

  • list_obj_to_create (Optional[List[str]]) – the objects to create in the container. This list contains all names of the objects. These names must be in the obj_init dictionary keys. May be None or empty

Return type:

None

class pymasep.common.initializer.InitializerContainerInterface(game, initializer_dict)

Bases: pymasep.common.initializer.initializer_container.InitializerContainer

Initializer used to initialize a Container by the interface An initializer can be executed by the Engine (by default) or processed by the Interface.

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • type: type of initialization. ALL: all the objects in obj_init will be created. BUY: the player must choose the objects to buy

  • obj_initdictionary containing the name of the objects that could be created/bought as the keys.

    Values are dictionaries with 3 keys: “cost”, the cost of the object, ‘template’: the template to create the object and ‘initializer’ used to initialize the object.

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

init_type

initializer by interface

apply(base_object)

Apply the initializer. Do nothing since it is an interface initializer.

Parameters:

base_object – The BaseObject to initialize

Return type:

None

class pymasep.common.initializer.InitializerFixed(game, initializer_dict)

Bases: pymasep.common.initializer.initializer.Initializer

Initialize Characteristic with fixed value

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • value_type: for Characteristic, the type of the value (as string)

  • subclass_initializer: name of sub initializer used to initialize sub BaseObject.

    These initializers must already exist in the game

  • value: fixed value used to initialize the characteristic

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

fixed_value

value used to initialize the characteristic

apply(base_object)

Apply the initializer.

Parameters:

base_object – The characteristic to initialize

Return type:

None

class pymasep.common.initializer.InitializerObject(game, initializer_dict)

Bases: pymasep.common.initializer.initializer.Initializer

Initializer used to initialize an Object. An initializer can be executed by the Engine (by default) or processed by the Interface.

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • value_type: for Characteristic, the type of the value (as string)

  • subclass_initializer: name of sub initializer used to initialize sub BaseObject. For an object, the name of the subclass_initializer must be ‘objectstate’. These initializers must already exist in the game

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

apply(one_object)

Apply the initializer for an Object. Apply the initializer of the ObjectState

Parameters:

one_object – The Object to initialize

class pymasep.common.initializer.InitializerObjectInterface(game, initializer_dict)

Bases: pymasep.common.initializer.initializer_object.InitializerObject

Initializer used to initialize an Object from the interface.

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • value_type: for Characteristic, the type of the value (as string)

  • subclass_initializer: name of sub initializer used to initialize sub BaseObject.

    For an object, the name of the subclass_initializer must be ‘objectstate’ These initializers must already exist in the game.

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

init_type

initializer by interface

class pymasep.common.initializer.InitializerObjectState(game, initializer_dict)

Bases: pymasep.common.initializer.initializer.Initializer

Initializer used to initialize an ObjectState. An initializer can be executed by the Engine (by default) or processed by the Interface.

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • value_type: for Characteristic, the type of the value (as string)

  • subclass_initializer: name of sub initializer used to initialize sub BaseObject.
    For an object, the name of the subclass_initializer must be ‘objectstate’.

    These initializers must already exist in the game.

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

apply(object_state)

Apply the initializer for an ObjectState. Apply the initializer of oll Characteristics

Parameters:

object_state – The ObjectState to initialize

class pymasep.common.initializer.InitializerObjectStateInterface(game, initializer_dict)

Bases: pymasep.common.initializer.initializer_object_state.InitializerObjectState

Initializer used to initialize an ObjectState from the interface.

An initializer is created from a dictionary. The format is the following:

  • name: name of the initializer used as id

  • value_type: for Characteristic, the type of the value (as string)

  • subclass_initializer: name of sub initializer used to initialize sub BaseObject. For an object, the name of the subclass_initializer must be ‘objectstate’. These initializers must already exist in the game.

Parameters:
  • game – the game where the initializer is created

  • initializer_dict (dict) – the dictionary used to create the initializer

init_type

initializer by interface