Package breitband.GUI

Class GameWindow

  • All Implemented Interfaces:
    breitband.preset.PlayerGUIAccess

    public class GameWindow
    extends java.lang.Object
    implements breitband.preset.PlayerGUIAccess
    The GUI for the game

    Contains various menus, buttons, and a map for interacting with / visualizing the game. To use the GameWindow, you will need to pass a board using the setBoard(breitband.game.board.Board) method. This board will then be used to update the game state on the GUI side after each move.

    A HumanPlayer is granted access to the GameWindow through the PlayerGUIAccess interface which the GameWindow implements.

    Author:
    Juno Veenstra
    • Constructor Summary

      Constructors 
      Constructor Description
      GameWindow​(java.lang.String[] playerNames, java.awt.Color[] playerColors, breitband.preset.PlayerType[] playerTypes, float soundVolume)
      Constructor to create a frame with a loading screen.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cheaterDetected()
      To be called when someone cheated.
      void gameOver​(breitband.preset.ImmutableList<java.lang.Integer> scores)
      Shows a game over screen.
      java.awt.Color getPlayerColor​(int index)
      Get a player's color by index
      java.lang.String getPlayerName​(int index)
      Get a player's name by index
      boolean hasLoaded()
      Returns true only if the GUI has finished loading
      void lastRound()
      Displays a pop-up message indicating that the last round has started
      breitband.preset.Move requestMoveFromCurrentHumanPlayer()
      Method called by human players to start taking GUI inputs
      void setBoard​(Board guiBoard)
      Sets the windows' Board and initializes it.
      void setCredits​(MapCredits mapCredits)
      Set OSM credits
      void updateGUIBoard​(breitband.preset.Move move)
      Method called at the end of every turn to keep the GUI's board updated
      void waitForInputs()
      Method for notifying waitForMove() so it wakes up Called once all information necessary for the Move has been gathered
      breitband.preset.Move waitForMove()
      Method called by the gui when a move is requested
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • toastNotifier

        public static ToastNotifier toastNotifier
        The global toast notifier system.

        This is how errors and other messages are visually displayed inside the GUI

      • tooltip

        public static Tooltip tooltip
      • targetCities

        public final GCity[] targetCities
        CityA at 0 and CityB at 1
    • Constructor Detail

      • GameWindow

        public GameWindow​(java.lang.String[] playerNames,
                          java.awt.Color[] playerColors,
                          breitband.preset.PlayerType[] playerTypes,
                          float soundVolume)
        Constructor to create a frame with a loading screen.

        Nothing else will be displayed until setBoard(breitband.game.board.Board) is called.

        Parameters:
        playerNames - The names of all players
        playerColors - The chosen colors of all players
        playerTypes - The types of all players
        soundVolume - The volume of the sound effects
    • Method Detail

      • waitForMove

        public breitband.preset.Move waitForMove()
        Method called by the gui when a move is requested

        Uses wait and notify to wait for the player to complete their GUI inputs and return a move once it's done

        Returns:
        The move created through inputs
      • requestMoveFromCurrentHumanPlayer

        public breitband.preset.Move requestMoveFromCurrentHumanPlayer()
        Method called by human players to start taking GUI inputs

        Constructs a move and returns it once done

        Specified by:
        requestMoveFromCurrentHumanPlayer in interface breitband.preset.PlayerGUIAccess
      • updateGUIBoard

        public void updateGUIBoard​(breitband.preset.Move move)
        Method called at the end of every turn to keep the GUI's board updated
        Parameters:
        move - latest move
      • setBoard

        public void setBoard​(Board guiBoard)
        Sets the windows' Board and initializes it.

        The game window will only show after this method is called and the relevant information has been read from the board.

        Parameters:
        guiBoard - Board to be used by GUI
      • setCredits

        public void setCredits​(MapCredits mapCredits)
        Set OSM credits
        Parameters:
        mapCredits - Credits read from config
      • getPlayerName

        public java.lang.String getPlayerName​(int index)
        Get a player's name by index
        Parameters:
        index - Player's index
        Returns:
        Player name
      • getPlayerColor

        public java.awt.Color getPlayerColor​(int index)
        Get a player's color by index
        Parameters:
        index - Player's index
        Returns:
        Player color
      • waitForInputs

        public void waitForInputs()
        Method for notifying waitForMove() so it wakes up Called once all information necessary for the Move has been gathered
      • gameOver

        public void gameOver​(breitband.preset.ImmutableList<java.lang.Integer> scores)
        Shows a game over screen.

        The first, second and last place players are on a podium. All other players, if present, are standing in front of the podium. Text labels indicate their names and scores.

        Parameters:
        scores - The scores of all players, in order of their IDs
      • cheaterDetected

        public void cheaterDetected()
        To be called when someone cheated.

        All players weep against a dark red background.

      • lastRound

        public void lastRound()
        Displays a pop-up message indicating that the last round has started
      • hasLoaded

        public boolean hasLoaded()
        Returns true only if the GUI has finished loading
        Returns:
        Whether the GUI has been fully loaded