The player module contains the functions and classes necessary to manipulate players in a minigame world.
The module contains a class that lets players control the behavior of their minigame counterpart by moving in a given direction, collecting an item, etc. (
CSPlayer). To prevent accidental manipulation of the original world data, the player class uses its own position property to update its location.
The base class for a player in the minigame world.
The player object contains methods for manipulating the current player’s position and inventory system.
Construct the Player object.
- in_world (CSWorld): The world the player is located in.
- **kwargs (dict): Arbitrary keyword arguments.
- at_position (tuple): The position the player should be placed in. Defaults to the player position in the world (
- with_inv (list): A list containing items that the player will have to start. Defaults to an empty list.
- vm: The virtual machine writer, if available.
Get the player’s current position.
- position (tuple): The current coordinates of the player.
Get the original starting position of the player.
- origin (tuple): The coordinates of the player’s original position.
Get the the count of how many items the player has.
- count (int): The number of items in the inventory.
Determine whether a player is blocked at a given position.
- blocked (bool): True if any walls are near the player (1-block radius).
Move the player in a direction, if the direction results in the player being able to move into a non-walled area.
- direction (str): The direction the player should move in. Acceptable directions are
- player (CSPlayer): The Player that committed the move action. This is useful in cases where chaining methods is preferred.
Add an item into the player’s inventory at the player’s current position.
If the item does not exist in the world, or the player already has the item in question, nothing occurs.
- player (CSPlayer): The Player object that committed the collect action. This is useful in cases where chaining methods is preferred.
Exit the level, if possible.
If a VM is specified, the VM writer will also close the writer by writing to the VM file.