Immovable

This module contains the Immovable and Actionable classes.

Immovable(**kwargs) This class derive BoardItem and describe an object that cannot move or be moved (like a wall).
Actionable(**kwargs) This class derives Immovable.
class gamelib.Immovable.Actionable(**kwargs)

Bases: gamelib.Immovable.Immovable

This class derives Immovable. It adds the ability to an Immovable BoardItem to be triggered and execute some code.

Parameters:
  • action (function) – the reference to a function (Attention: no parentheses at the end of the function name).
  • action_parameters (list) – the parameters to the action function.
  • perm (Constants) – The permission that defines what types of items can actually activate the actionable. The permission has to be one of the permissions defined in Constants

On top of these parameters Actionable accepts all parameters from Immovable and therefor from BoardItem.

Note

The common way to use this class is to use GenericActionableStructure. Please refer to GenericActionableStructure for more details.

activate()

This function is calling the action function with the action_parameters.

Usually it’s automatically called by move() when a Player or NPC (see Characters)

can_move()

Return the capability of moving of an item.

Obviously an Immovable item is not capable of moving. So that method always returns False.

Returns:False
Return type:bool
debug_info()

Return a string with the list of the attributes and their current value.

Return type:str
display()

Print the model WITHOUT carriage return.

overlappable()

This is a virtual method that must be implemented in deriving class. This method has to return True or False. This represent the capacity for a BoardItem to be overlapped by another BoardItem.

pickable()

This is a virtual method that must be implemented in deriving class. This method has to return True or False. This represent the capacity for a BoardItem to be pick-up by player or NPC.

restorable()

This is a virtual method that must be implemented in deriving class. This method has to return True or False. This represent the capacity for an Immovable BoardItem to be restored by the board if the item is overlappable and has been overlapped by another Movable (Movable) item.

size()

Return the size of the Immovable Item.

Returns:The size of the item.
Return type:int
store_position(row, column)

Store the BoardItem position for self access.

The stored position is used for consistency and quick access to the self postion. It is a redundant information and might not be synchronized.

Parameters:
  • row (int) – the row of the item in the Board.
  • column (int) – the column of the item in the Board.

Example:

item.store_position(3,4)
class gamelib.Immovable.Immovable(**kwargs)

Bases: gamelib.BoardItem.BoardItem

This class derive BoardItem and describe an object that cannot move or be moved (like a wall). Thus this class implements BoardItem.can_move(). However it does not implement BoardItem.pickable() or BoardItem.overlappable()

can_move()

Return the capability of moving of an item.

Obviously an Immovable item is not capable of moving. So that method always returns False.

Returns:False
Return type:bool
debug_info()

Return a string with the list of the attributes and their current value.

Return type:str
display()

Print the model WITHOUT carriage return.

overlappable()

This is a virtual method that must be implemented in deriving class. This method has to return True or False. This represent the capacity for a BoardItem to be overlapped by another BoardItem.

pickable()

This is a virtual method that must be implemented in deriving class. This method has to return True or False. This represent the capacity for a BoardItem to be pick-up by player or NPC.

restorable()

This is a virtual method that must be implemented in deriving class. This method has to return True or False. This represent the capacity for an Immovable BoardItem to be restored by the board if the item is overlappable and has been overlapped by another Movable (Movable) item.

size()

Return the size of the Immovable Item.

Returns:The size of the item.
Return type:int
store_position(row, column)

Store the BoardItem position for self access.

The stored position is used for consistency and quick access to the self postion. It is a redundant information and might not be synchronized.

Parameters:
  • row (int) – the row of the item in the Board.
  • column (int) – the column of the item in the Board.

Example:

item.store_position(3,4)