Movable

This module contains the Movable class. It can potentially hold more movement related classes.

class gamelib.Movable.Movable(**kwargs)

A class representing BoardItem capable of movements.

Movable subclasses BoardItem.

Parameters:step (int) – the amount of cell a movable can cross in one turn.

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

This class contains a private member called _overlapping. This private member is used to store the reference to an overlappable object while a movable occupy its position. The Board then restore the overlapped object. You should let the Board class take care of that.

can_move()

Movable implements can_move().

Returns:True
Return type:Boolean
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.

has_inventory()

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 Movable to have an inventory.

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)