Package sac.model

Class Model

java.lang.Object
sac.model.Model

public class Model extends Object
The model for a Tetris Game.

This class acts as a wrapper for Board with extra functionality.

  • Field Details

    • board

      public Board board
  • Constructor Details

    • Model

      public Model()
      Initialize a new model.
  • Method Details

    • setGameMode

      public void setGameMode(GameMode gameMode)
      Set the game mode.

      Note: GameMode stores the actual game logic.

      Parameters:
      gameMode - The desired GameMode.
    • newGame

      public void newGame()
      Clear the current game and create a new one.
    • startGame

      public void startGame()
      Start the game.
    • modelTick

      public void modelTick(Model.MoveType moveType)
      Update the model by moveType
      Parameters:
      moveType - The movement.
    • isGameOn

      public boolean isGameOn()
      Check if the game is on.
      Returns:
      If the game is on.
    • getGhostPiecePositions

      public List<Point> getGhostPiecePositions()
      Calculate the ghost piece of current piece.
      Returns:
      A list of point representing the body of the ghost piece.
    • getHoldPiece

      public Piece.PieceType getHoldPiece()
      Get the current piece being held.
      Returns:
      The piece being held.
    • getPreview

      public ArrayDeque<Piece> getPreview()
      Get the upcoming pieces.
      Returns:
      A list of upcoming pieces.