Class BattleMenu

java.lang.Object
com.mg105.user_interface.BattleMenu
All Implemented Interfaces:
BattleMenuInterface, Toggleable, EventListener, javafx.event.EventHandler<javafx.event.ActionEvent>

public class BattleMenu extends Object implements javafx.event.EventHandler<javafx.event.ActionEvent>, BattleMenuInterface, Toggleable
This class uses JavaFX and is displayed during an active battle.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new BattleMenu.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull javafx.scene.Scene
    Get the scene of this toggleable object.
    void
    handle(javafx.event.ActionEvent event)
    Handles button events.
    void
    setNames(String[] playerNames, String[] opponentNames)
    Sets the names of the player and opponent characters participating in the active battle.
    void
    toggle(boolean isVisible)
    Set the visibility of this component.
    void
    Updates the display corresponding to the given affected character.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BattleMenu

      public BattleMenu(BattlePresenter battlePres)
      Creates a new BattleMenu. Sets every UI element, except for labels which are set when the view is toggled on.
      Parameters:
      battlePres - the BattlePresenter to refer to (following MVP pattern)
  • Method Details

    • setNames

      public void setNames(String[] playerNames, String[] opponentNames)
      Sets the names of the player and opponent characters participating in the active battle.
      Specified by:
      setNames in interface BattleMenuInterface
      Parameters:
      playerNames - array of name Strings representing player characters.
      opponentNames - array of name Strings representing opponents.
    • updateCharacter

      public void updateCharacter(String character)
      Updates the display corresponding to the given affected character.
      Specified by:
      updateCharacter in interface BattleMenuInterface
      Parameters:
      character - the character who needs to be updated on the screen.
    • getScene

      @NotNull public @NotNull javafx.scene.Scene getScene()
      Get the scene of this toggleable object. It is this scene that will be displayed.
      Specified by:
      getScene in interface Toggleable
      Returns:
      the scene to be displayed.
    • toggle

      public void toggle(boolean isVisible)
      Set the visibility of this component.
      Specified by:
      toggle in interface Toggleable
      Parameters:
      isVisible - true if the Toggleable is now visible, false otherwise. If false the Toggleable is expected to do nothing on ANY user inputs.
    • handle

      public void handle(javafx.event.ActionEvent event)
      Handles button events. NextRound will start the next round, which is handled in BattlePresenter. The two move buttons represent a move to be selected, and will cause target buttons to appear next to valid target characters and the move buttons to disappear. The target buttons only become visible when the character they represent can be targeted with the selected move, and pressing them will apply the move onto the character and make the target buttons disappear.
      Specified by:
      handle in interface javafx.event.EventHandler<javafx.event.ActionEvent>
      Parameters:
      event - the event which occurred.