Class GameServiceVs

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

public class GameServiceVs extends Object implements IGameService
Implementation of the IGameService interface for a two-player game. Provides methods to manage and control the game state and its components.
  • Constructor Details

    • GameServiceVs

      public GameServiceVs(IGameModel gameModel)
      Constructor for GameServiceVs. Uses the factory pattern to initialize the maze, player, and second player 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 second player's start 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 players and maze.
      Specified by:
      resetGame in interface IGameService
    • movePlayer

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

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

      public List<int[]> getHint()
      Provides a hint for the players 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.
    • getPlayerService

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

      public IAiService getAiService()
      This version does not use AI services.
      Specified by:
      getAiService in interface IGameService
      Returns:
      Null as AI functionality is not required.
    • getMazeService

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

      public IPlayerService getSecondPlayerService()
      Gets the second player service instance.
      Specified by:
      getSecondPlayerService in interface IGameService
      Returns:
      The second player service instance.