Class GameService

java.lang.Object
com.edu.xmum.CST210.Service.GameService
All Implemented Interfaces:
IGameService

public class GameService extends Object implements IGameService
Implementation of the IGameService interface. Provides methods to manage and control the game state and its components.
  • Constructor Details

    • GameService

      public GameService(IGameModel gameModel)
      Constructor for GameService. Uses the factory pattern to initialize the maze, player, and AI services.
      Parameters:
      gameModel - The game model instance.
  • Method Details

    • setDifficulty

      public void setDifficulty(Difficulty difficulty)
      Sets the game difficulty by adjusting the maze size and AI position.
      Specified by:
      setDifficulty in interface IGameService
      Parameters:
      difficulty - The difficulty level to set.
    • resetGame

      public void resetGame()
      Resets the game to its initial state, including player, maze, and AI.
      Specified by:
      resetGame in interface IGameService
    • movePlayer

      public boolean movePlayer(Direction direction)
      Moves the player in the specified direction.
      Specified by:
      movePlayer in interface IGameService
      Parameters:
      direction - The direction to move the player.
      Returns:
      True if the move is valid and the player is moved, false otherwise.
    • getHint

      public List<int[]> getHint()
      Provides a hint for the player by returning the path to the goal.
      Specified by:
      getHint in interface IGameService
      Returns:
      A list of coordinate pairs representing the path to the goal.
    • moveSecondPlayer

      public boolean moveSecondPlayer(Direction direction)
      This version does not require a second player.
      Specified by:
      moveSecondPlayer in interface IGameService
      Parameters:
      direction - The direction to move the second player.
      Returns:
      False as second player functionality is not required.
    • getPlayerService

      public IPlayerService getPlayerService()
      Gets the player service instance.
      Specified by:
      getPlayerService in interface IGameService
      Returns:
      The player service instance.
    • getAiService

      public IAiService getAiService()
      Gets the AI service instance.
      Specified by:
      getAiService in interface IGameService
      Returns:
      The AI service instance.
    • getMazeService

      public IMazeService getMazeService()
      Gets the maze service instance.
      Specified by:
      getMazeService in interface IGameService
      Returns:
      The maze service instance.
    • getSecondPlayerService

      public IPlayerService getSecondPlayerService()
      This version does not require a second player.
      Specified by:
      getSecondPlayerService in interface IGameService
      Returns:
      Null as second player functionality is not required.