actions module¶
Actions are behaviors an Actor can perform They are attached to Actor entities
- class actions.Action(entity: Actor)¶
Bases:
objectDefines the base class for all actions The ‘perform’ method must be implemented by all subclasses Are those subclasses? How does OOP work in Python?
- property engine: Engine¶
Returns the Engine that this action is performed in. The engine is related to the gamemap that is referenced by the entity
- Returns
The engine running the gamemap that the entity existis in
- Return type
Engine
- perform() None¶
Perform this action with the objects needed tio determine its scope. self.engine is the scope this action is being perfomed in self.entity is the object performing the action
This method must be overridden by Action subclasses.
- class actions.ActionWithDirection(entity: Actor, dx: int, dy: int)¶
Bases:
actions.ActionSub class of Action that includes a direction Should be implemented by subclasses
- Parameters
Action (Action) – Parent’s class
- property blocking_entity: Optional[Entity]¶
Return the blocking entity at this actions destination
- Returns
Blocking entity at destination
- Return type
Optional[Entity]
- property dest_xy: Tuple[int, int]¶
Returns this actions destination It is the current entior’s location plus the direction it is supposed to take
- Returns
X,Y Coordinates of destination
- Return type
Tuple[int, int]
- perform() None¶
Method should be implemented by subclasses
- Raises
NotImplementedError – [description]
- class actions.BumpAction(entity: Actor, dx: int, dy: int)¶
Bases:
actions.ActionWithDirectionBumps into an entity If entity is an actor, self.actor attemps to attack it If not, attemps to move actor.
- Parameters
ActionWithDirection (ActionWithDirection) – Parent’s class
- perform() None¶
If target is actor, returns a melee attack action that returns None Else, returns a move action that returns None
- Returns
Implementation of ActionWithDirection
- Return type
None
- class actions.DropItem(entity: Actor)¶
Bases:
actions.ActionDrop item from inventory
- Parameters
Action (Action) – Parent class
- perform() None¶
Passes item to entity’s inventory so it can be dropped
- class actions.EquipAction(entity: Actor, item: Item)¶
Bases:
actions.ActionEquips equipabble item
- Parameters
Action (Action) – Parent’s class
- perform() None¶
Passes item to entity’s inventory so it can be equipped OR unequips Basically toggle_equip eh?
- class actions.ItemAction(entity: Actor, item: Item, target_xy: Optional[Tuple[int, int]] = None)¶
Bases:
actions.ActionAction related to using an Item
- Parameters
Action (Action) – Again this is a subclass?
- perform() None¶
Performs the action, the Item should know how it activates itself.
- class actions.MeleeAction(entity: Actor, dx: int, dy: int)¶
Bases:
actions.ActionWithDirectionAttacks at direction
- Parameters
ActionWithDirection (ActionWithDirection) – Parent’s class
- perform() None¶
Attemps to attack Actor at direction
- Raises
exceptions.Impossible – If no target to attack
- class actions.MovementAction(entity: Actor, dx: int, dy: int)¶
Bases:
actions.ActionWithDirectionAttemps to move actor to direction If destination is out of bounds, blocked by entity or non-walkable will :raises exceptions.Impossible:
- Parameters
ActionWithDirection (ActionWithDirection) – Parent’s Class
- perform() None¶
Checks if destition is reachable, if not :raises exceptions.Impossible:
- class actions.PickupAction(entity: Actor)¶
Bases:
actions.ActionAction when an entity will pick up an item from a tile
- Parameters
Action (Action) – Since it’s just the parent class, should we even comment it?
- perform() None¶
The actual performance In this case, Actor will attempt to pick up an item from the tile This might raise exceptions.Impossible if there is nothing to pickup or if inventory is full
- class actions.TakeStairsAction(entity: Actor)¶
Bases:
actions.ActionTo make our character go down a set of stairs
- Parameters
Action (Action) – Parent’s class
- perform() None¶
Attemps to take the stairs, will raise exceptions.Impossible if there are no stairs
- class actions.WaitAction(entity: Actor)¶
Bases:
actions.ActionAction that does nothing but passes a turn
- Parameters
Action (Action) – Parent’s class
- perform() None¶
Don’t do anything, just pass the turn