Controllers Package#
Submodules#
Controller Class#
- class game.controllers.controller.Controller[source]#
Bases:
objectController Class Notes:
This is a super class for every controller type that is necessary for inheritance. Think of it as the GameObject class for Controllers.
The handle_actions method is important and will specify what each controller does when interacting with the Player object’s avatar.
Refer to the other controller files for a more detailed description on how they work. If more controllers are ever needed, add them to facilitate the flow of the game.
- handle_actions(action: ActionType, client: Player, world: GameBoard)[source]#
Interact Controller Class#
- class game.controllers.interact_controller.InteractController[source]#
Bases:
ControllerInteract Controller Notes:
The Interact Controller manages the actions the player tries to execute. As the game is played, a player can interact with surrounding, adjacent stations and the space they’re currently standing on.
Example:
x x x x x x x x x O x x O A O x x O x x x x x x x
The given visual shows what players can interact with. “A” represents the avatar; “O” represents the spaces that can be interacted with (including where the “A” is); and “x” represents the walls and map border.
These interactions are managed by using the provided ActionType enums in the enums.py file.
- handle_actions(action: ActionType, client: Player, world: GameBoard) None[source]#
Given the ActionType for interacting in a direction, the Player’s avatar will engage with the object. :param action: :param client: :param world: :return: None
Inventory Controller Class#
- class game.controllers.inventory_controller.InventoryController[source]#
Bases:
ControllerInteract Controller Notes:
The Inventory Controller is how player’s can manage and interact with their inventory. When given the enum to select an item from a slot in the inventory, that will then become the held item.
If an enum is passed in that is not within the range of the inventory size, an error will be thrown.
- handle_actions(action: ActionType, client: Player, world: GameBoard) None[source]#
Master Controller Class#
- class game.controllers.master_controller.MasterController[source]#
Bases:
ControllerMaster Controller Notes:
- Give Client Objects:
Takes a list of Player objects and places each one in the game world.
- Game Loop Logic:
Increments the turn count as the game plays (look at the engine to see how it’s controlled more).
- Interpret Current Turn Data:
This accesses the gameboard in the first turn of the game and generates the game’s seed.
- Client Turn Arguments:
There are lines of code commented out that create Action Objects instead of using the enum. If your project needs Actions Objects instead of the enums, comment out the enums and use Objects as necessary.
- Turn Logic:
This method executes every movement and interact behavior from every client in the game. This is done by using every other type of Controller object that was created in the project that needs to be managed here (InteractController, MovementController, other game-specific controllers, etc.).
- Create Turn Log:
This method creates a dictionary that stores the turn, all client objects, and the gameboard’s JSON file to be used as the turn log.
- Return Final Results:
This method creates a dictionary that stores a list of the clients’ JSON files. This represents the final results of the game.
- create_turn_log(clients: list[game.common.player.Player], turn: int)[source]#
- give_clients_objects(clients: list[game.common.player.Player], world: dict)[source]#
- interpret_current_turn_data(clients: list[game.common.player.Player], world: dict, turn)[source]#
- return_final_results(clients: list[game.common.player.Player], turn)[source]#
- turn_logic(clients: list[game.common.player.Player], turn)[source]#
Movement Controller Class#
- class game.controllers.movement_controller.MovementController[source]#
Bases:
ControllerMovement Controller Notes:
The Movement Controller manages the movement actions the player tries to execute. Players can move up, down, left, and right. If the player tries to move into a space that’s impassable, they don’t move.
For example, if the player attempts to move into an Occupiable Station (something the player can be on) that is occupied by a Wall object (something the player can’t be on), the player doesn’t move; that is, if the player tries to move into anything that can’t be occupied by something, they won’t move.
- handle_actions(action: ActionType, client: Player, world: GameBoard)[source]#
Place Controller Class#
- class game.controllers.place_controller.PlaceController[source]#
Bases:
Controller- handle_actions(action: ActionType, client: Player, world: GameBoard)[source]#