BoardItem

This module contains the basic board items classes (regular and void items).

class gamelib.BoardItem.BoardItem(**kwargs)

Base class for any item that will be placed on a Board.

Parameters:
  • type (str) – A type you want to give your item. It can be any string. You can then use the type for sorting or grouping for example.
  • name (str) – A name for this item. For identification purpose.
  • pos (array) – the position of this item. When the item is managed by the Board and Game engine this member hold the last updated position of the item. It is not updated if you manually move the item. It must be an array of 2 integers [row,column]
  • model (str) – The model to use to display this item on the Board. Be mindful of the space it will require. Default value is ‘*’.
can_move()

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

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.

size()

This is a virtual method that must be implemented in deriving class. This method has to return an integer. This represent the size of the BoardItem. It is used for example to evaluate the space taken in the inventory.

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.BoardItem.BoardItemVoid(**kwargs)

A class that represent a void cell.

overlappable()

A BoardItemVoid is obviously overlappable (so player and NPC can walk over).

Returns:True
pickable()

A BoardItemVoid is not pickable, therefor this method return false.

Returns:False