Class GameInstance

java.lang.Object
com.mygdx.game.Logic.GameInstance
All Implemented Interfaces:
java.io.Serializable

public class GameInstance
extends java.lang.Object
implements java.io.Serializable
The "main" class of the Game. Contains the rules and connects the Logic segment of the project together. This is the class that gets serialized when saving the game.
See Also:
Serialized Form
  • Constructor Details

    • GameInstance

      public GameInstance​(int numberOfPlayers)
      Parameters:
      numberOfPlayers - Number of players that play the game. Works with any possitive number but normal values are in [2,8]
  • Method Details

    • initialize

      public void initialize()
    • drawCard

      public void drawCard​(Card card)
      Called by CardSquare to notify the UI so that it can display a message to the user MoveCard and JailCard.
      Objects also need to set their resulting square to the current board. It need to be at runtime because cards are constructed using csv files with no reference to the current Board
      Parameters:
      card - The Card that has been drawn
    • gameLoop

      public void gameLoop​(int dice)
      To be called by the UI at the start of the turn.
      Moves the player, runs the action of the resulting square and checks if player passed start
      Parameters:
      dice - By how many squares should the Pawn move.
    • endTurn

      public void endTurn()
      To be called by the UI when the player finished his turn
      Checks if the player lost or won and proceeds to the next player
    • getPlayers

      public java.util.ArrayList<Player> getPlayers()
    • getNumberOfPlayers

      public int getNumberOfPlayers()
    • getBoard

      public Board getBoard()
    • getCurrentPlayer

      public Player getCurrentPlayer()
    • setCurrentPlayer

      public void setCurrentPlayer​(int i)
    • getListener

      public GameInstance.GameInstanceListener getListener()
    • setListener

      public void setListener​(GameInstance.GameInstanceListener listener)