Package pacManReloaded.server

## Class GameLogic

- java.lang.Object
- - pacManReloaded.server.GameLogic

- All Implemented Interfaces:
    `INavigator`

      public class GameLogic
      extends java.lang.Object
      implements INavigator

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `GameState` | `gameState` |
    `Map` | `map` |
    `java.util.ArrayList<Player>` | `players` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `GameLogic()` | Dummy-Constructor for Unit tests
    `GameLogic​(java.util.ArrayList<Player> players, Server server)` | Constructor of the Class, starts a game with the players and server as parameters

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `checkSuperPower()` | checks if super power is active, while active the ghosts will get a message so they know the PacMans are able to hunt them
    `void` | `collisionWithBallGhost​(Ball o)` | handles the collision by a ghost with a ball, updates score and the game state, removes the ball on the map
    `void` | `collisionWithBallPacMan​(Ball o)` | handles the collision by a pacman with a ball, updates score and the game state, removes the ball on the map
    `void` | `collisionWithPowerballGhost​(PowerBall o)` | handles the collision by a ghost with a powerball, updates score and the game state, removes the ball on the map
    `void` | `collisionWithPowerballPacMan​(PowerBall o)` | handles the collision by a pacman with a powerball, updates score and the game state, removes the ball on the map
    `void` | `createBall​(java.awt.geom.Point2D.Float point)` | creates new ball and adds it to the appropriate list
    `void` | `detectCollisions()` | this method finds out of the next step of an actor is a collision with another object/wall
    `void` | `doPlay()` | decides which part of the game will happens next, depending on the game status
    `java.awt.geom.Point2D.Float` | `getExitPosition()` |
    `GameState` | `getGameState()` | "getter" for the game state
    `GameStatus` | `getGameStatus()` | "getter" for the game status
    `float` | `getMapSize()` |
    `java.lang.Object` | `getObjectAtPosition​(java.awt.geom.Point2D.Float position)` |
    `PacMan` | `getPacman()` | "getter" for the PacMans
    `java.awt.geom.Point2D.Float` | `getPacmanPosition()` |
    `boolean` | `isDone()` | method which checks if the game is over/done
    `boolean` | `isInSpawn​(Ghost ghost)` |
    `void` | `nextMove()` | allows all actors to perform their next step, in addition, calls the operation checkSuperPower() and detectCollision().
    `void` | `removeObject​(Ball o)` | removes the object from the map
    `void` | `setGameStatus​(GameStatus gameStatus)` | "setter" for the game status

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### gameState

          public GameState gameState

    - #### map

          public Map map

    - #### players

          public java.util.ArrayList<Player> players

  - ### Constructor Detail

    - #### GameLogic

          public GameLogic​(java.util.ArrayList<Player> players,
                           Server server)

      Constructor of the Class, starts a game with the players and server as parameters
      Parameters:
        `players` - the players who will be in the game as arraylist
        `server` - the server where the game will be played on

    - #### GameLogic

          public GameLogic()

      Dummy-Constructor for Unit tests

  - ### Method Detail

    - #### nextMove

          public void nextMove()

      allows all actors to perform their next step, in addition, calls the operation checkSuperPower() and detectCollision().

    - #### detectCollisions

          public void detectCollisions()

      this method finds out of the next step of an actor is a collision with another object/wall

    - #### collisionWithPowerballPacMan

          public void collisionWithPowerballPacMan​(PowerBall o)

      handles the collision by a pacman with a powerball, updates score and the game state, removes the ball on the map
      Parameters:
        `o` - the powerball on the map

    - #### collisionWithPowerballGhost

          public void collisionWithPowerballGhost​(PowerBall o)

      handles the collision by a ghost with a powerball, updates score and the game state, removes the ball on the map
      Parameters:
        `o` - the powerball on the map

    - #### removeObject

          public void removeObject​(Ball o)

      removes the object from the map
      Parameters:
        `o` - the object getting removed

    - #### collisionWithBallPacMan

          public void collisionWithBallPacMan​(Ball o)

      handles the collision by a pacman with a ball, updates score and the game state, removes the ball on the map
      Parameters:
        `o` - the ball on the map

    - #### collisionWithBallGhost

          public void collisionWithBallGhost​(Ball o)

      handles the collision by a ghost with a ball, updates score and the game state, removes the ball on the map
      Parameters:
        `o` - the ball on the map

    - #### getPacman

          public PacMan getPacman()

      "getter" for the PacMans
      Returns:
        players who are PacMans

    - #### checkSuperPower

          public void checkSuperPower()

      checks if super power is active, while active the ghosts will get a message so they know the PacMans are able to hunt them

    - #### createBall

          public void createBall​(java.awt.geom.Point2D.Float point)

      creates new ball and adds it to the appropriate list

    - #### doPlay

          public void doPlay()

      decides which part of the game will happens next, depending on the game status

    - #### isDone

          public boolean isDone()

      method which checks if the game is over/done
      Returns:
        true: game is over; false: game not over yet

    - #### getGameStatus

          public GameStatus getGameStatus()

      "getter" for the game status
      Returns:
        the actual game status

    - #### setGameStatus

          public void setGameStatus​(GameStatus gameStatus)

      "setter" for the game status
      Parameters:
        `gameStatus` - the game status

    - #### getObjectAtPosition

          public java.lang.Object getObjectAtPosition​(java.awt.geom.Point2D.Float position)

      Specified by:
        `getObjectAtPosition` in interface `INavigator`

    - #### getMapSize

          public float getMapSize()

      Specified by:
        `getMapSize` in interface `INavigator`

    - #### getPacmanPosition

          public java.awt.geom.Point2D.Float getPacmanPosition()

      Specified by:
        `getPacmanPosition` in interface `INavigator`

    - #### getExitPosition

          public java.awt.geom.Point2D.Float getExitPosition()

      Specified by:
        `getExitPosition` in interface `INavigator`

    - #### isInSpawn

          public boolean isInSpawn​(Ghost ghost)

      Specified by:
        `isInSpawn` in interface `INavigator`

    - #### getGameState

          public GameState getGameState()

      "getter" for the game state
      Returns:
        the current game state