java.lang.Object
it.polimi.ingsw.am13.client.view.gui.LogGUI

public class LogGUI extends Object
Class that stores a log of the game for the GUI
  • Field Details

    • logMessages

      private final Queue<String> logMessages
      Messages currently saved. It's a queue storing only the still not handled log messages
    • gameState

      private final GameState gameState
      State of the game
  • Constructor Details

    • LogGUI

      public LogGUI(GameState gameState)
      Creates a new instance of the handler of the log for GUI
      Parameters:
      gameState - State of the game
  • Method Details

    • hasOtherLogs

      public boolean hasOtherLogs()
      Checks if there are other logs in the queue of messages (i.e. the queue is not empty)
      Returns:
      True is there are other logs to handle, false otherwise
    • popNextLog

      public String popNextLog()
      Sets the most old log as handled, deleting it (i.e. pops it from the queue)
      Returns:
      Deletes the currently handled log message
    • logStartGame

      public void logStartGame()
      Adds to the log that the game has started
    • logPlayedStarter

      public void logPlayedStarter(PlayerLobby player)
      Adds to the log that the specified player played the starter card
      Parameters:
      player - Player who played the starter card
    • logChosenPersonalObjective

      public void logChosenPersonalObjective(PlayerLobby player)
      Adds to the log that the specified player chosen their personal objective card
      Parameters:
      player - Player who chose the personal objective card
    • logPlayedCard

      public void logPlayedCard(PlayerLobby player, Coordinates coord, boolean pointsIncr)
      Adds to the log that the specified player played the a card on the specified coordinates
      Parameters:
      player - Player who played the card
      coord - Coordinates on which the card has been placed
    • logPickedCard

      public void logPickedCard(PlayerLobby player)
      Adds to the log that the specified player picked a card
      Parameters:
      player - Player who picked the card
    • logNextTurn

      public void logNextTurn()
      Adds to the log that the turn changed, and specifies the new current player
    • logFinalPhase

      public void logFinalPhase()
      Adds to the log that the final phase has been triggered
    • logUpdatePoints

      public void logUpdatePoints(Map<PlayerLobby,Integer> pointsDelta)
      Adds to the log that the points were updated
      Parameters:
      pointsDelta - Difference between the points now updated and before the update
    • logWinner

      public void logWinner()
      Adds to the log that the winner has been calculated
    • logDisconnect

      public void logDisconnect(PlayerLobby player)
      Adds to the log that the specified player disconnected
      Parameters:
      player - Player who disconnected
    • logReconnect

      public void logReconnect(PlayerLobby player)
      Adds to the log that the specified player reconnected
      Parameters:
      player - Player who reconnected
    • logMessageReceived

      public void logMessageReceived(PlayerLobby sender, boolean toAll)
      Adds to the log that a chat message and been received by the client
      Parameters:
      sender - Player who sent the message
      toAll - True if the message is to all the players, false if it's for a specific player
    • addToLog

      private void addToLog(PlayerLobby player, String log)
      Adds to the log a generic string, with the specified subject player
      Parameters:
      player - Player subject of the log (who triggered the action logged)
      log - String (without the time string and the subject) for the log
    • addToLog

      private void addToLog(String log)
      Adds to the log a generic string, with the server as subject of the log
      Parameters:
      log - String (without the time string and the subject) for the log
    • currentTimeString

      private String currentTimeString()
      Returns:
      Formatted string for the current time the log is stored