pymasep.common.initializer ========================== .. py:module:: pymasep.common.initializer Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pymasep/common/initializer/initializer/index /autoapi/pymasep/common/initializer/initializer_charac_interface/index /autoapi/pymasep/common/initializer/initializer_charac_interface_shared/index /autoapi/pymasep/common/initializer/initializer_container/index /autoapi/pymasep/common/initializer/initializer_container_interface/index /autoapi/pymasep/common/initializer/initializer_fixed/index /autoapi/pymasep/common/initializer/initializer_object/index /autoapi/pymasep/common/initializer/initializer_object_interface/index /autoapi/pymasep/common/initializer/initializer_object_state/index /autoapi/pymasep/common/initializer/initializer_object_state_interface/index Classes ------- .. autoapisummary:: pymasep.common.initializer.Initializer pymasep.common.initializer.InitializerCharacInterface pymasep.common.initializer.InitializerCharacInterfaceShared pymasep.common.initializer.InitializerContainer pymasep.common.initializer.InitializerContainerInterface pymasep.common.initializer.InitializerFixed pymasep.common.initializer.InitializerObject pymasep.common.initializer.InitializerObjectInterface pymasep.common.initializer.InitializerObjectState pymasep.common.initializer.InitializerObjectStateInterface Package Contents ---------------- .. py:class:: 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 :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:attribute:: INIT_TYPE_ENGINE :value: 'Engine' Initializer by the Engine .. py:attribute:: INIT_TYPE_INTERFACE :value: 'Interface' Initializer by the Interface .. py:attribute:: game .. py:attribute:: name name of the initializer used as id .. py:attribute:: value_type type of the value (as string) for Characteristic .. py:attribute:: subclass_initializer name of sub initializers used to initialize sub BaseObject .. py:attribute:: init_type initializer by engine by default .. py:method:: apply(base_object) Apply the initializer. :param base_object: The BaseObject to initialize .. py:class:: InitializerCharacInterface(game, initializer_dict) Bases: :py:obj:`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) :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:attribute:: VALUE_MODE_VALUE :value: 'value' Value is chosen in the interface .. py:attribute:: VALUE_MODE_DICE :value: 'dice' value is chosen by a dice interface .. py:attribute:: VALUE_MODE_CHOICE :value: 'choice' value is chosen in the interface among some choices .. py:attribute:: value_mode Way of choosing the initializer value. see VALUE_MODE_* .. py:attribute:: param parameter depending of initializer type .. py:attribute:: init_type initializer by interface .. py:class:: InitializerCharacInterfaceShared(game, initializer_dict) Bases: :py:obj:`pymasep.common.initializer.initializer_charac_interface.InitializerCharacInterface` Initializer to choose Characteristic with VALUE_MODE_CHOICE shared among multiple interface. :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:method:: filter_choice(charac_name, state) Filter choices when an interface chose a value, all others must remove this choice. :param charac_name: Characteristic name used to filter other characteristics :param state: state where the characteristic is stored :return: the new list of choices filtered removing the value of .. py:class:: InitializerContainer(game, initializer_dict) Bases: :py:obj:`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. :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:attribute:: type type of the initializer .. py:attribute:: obj_init object creation and initialization .. py:method:: apply(base_object) Apply the initializer. :param base_object: The Container to initialize with all objects in the initializer .. py:method:: apply_with_params(base_object, list_obj_to_create) Create objects in the container and set the container state as 'run' :param base_object: The Container to initialize with list_obj_to_create objects :param list_obj_to_create: 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 .. py:class:: InitializerContainerInterface(game, initializer_dict) Bases: :py:obj:`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_init : dictionary 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. :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:attribute:: init_type initializer by interface .. py:method:: apply(base_object) Apply the initializer. Do nothing since it is an interface initializer. :param base_object: The BaseObject to initialize .. py:class:: InitializerFixed(game, initializer_dict) Bases: :py:obj:`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 :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:attribute:: fixed_value value used to initialize the characteristic .. py:method:: apply(base_object) Apply the initializer. :param base_object: The characteristic to initialize .. py:class:: InitializerObject(game, initializer_dict) Bases: :py:obj:`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 :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:method:: apply(one_object) Apply the initializer for an Object. Apply the initializer of the ObjectState :param one_object: The Object to initialize .. py:class:: InitializerObjectInterface(game, initializer_dict) Bases: :py:obj:`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. :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:attribute:: init_type initializer by interface .. py:class:: InitializerObjectState(game, initializer_dict) Bases: :py:obj:`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. :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:method:: apply(object_state) Apply the initializer for an ObjectState. Apply the initializer of oll Characteristics :param object_state: The ObjectState to initialize .. py:class:: InitializerObjectStateInterface(game, initializer_dict) Bases: :py:obj:`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. :param game: the game where the initializer is created :param initializer_dict: the dictionary used to create the initializer .. py:attribute:: init_type initializer by interface