pymasep.common.initializer.initializer_container

Classes

InitializerContainer

Initializer used to initialize a Container

Module Contents

class pymasep.common.initializer.initializer_container.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