Interface PlacementHandler

All Known Implementing Classes:
PlacementUI

public interface PlacementHandler
Interface defining the necessary operations for handling the ship placement phase. It acts as a contract between the UI and the event listeners to manage user selections and transitions.
Author:
Alessio Cascini
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Retrieves the selected orientation (e.g., Horizontal or Vertical).
    int
    Retrieves the index of the currently selected ship from the UI.
    void
    Updates the UI to visually represent a ship that has been successfully placed.
    void
    proceedToGameUI(boolean isFirstPlayer)
    Transitions the application from the placement screen to the main game screen.
    void
    Displays a feedback message to the user, such as errors or instructions.
  • Method Details

    • getSelectedShipIndex

      int getSelectedShipIndex()
      Retrieves the index of the currently selected ship from the UI.
      Returns:
      The index of the selected ship in the fleet list
    • getSelectedOrientationIndex

      int getSelectedOrientationIndex()
      Retrieves the selected orientation (e.g., Horizontal or Vertical).
      Returns:
      The index representing the chosen orientation
    • showMessage

      void showMessage(String message)
      Displays a feedback message to the user, such as errors or instructions.
      Parameters:
      message - The string content to be displayed
    • highlightShipCells

      void highlightShipCells(Ship ship)
      Updates the UI to visually represent a ship that has been successfully placed.
      Parameters:
      ship - The Ship object containing the cells to be highlighted
    • proceedToGameUI

      void proceedToGameUI(boolean isFirstPlayer)
      Transitions the application from the placement screen to the main game screen.
      Parameters:
      isFirstPlayer - Boolean flag to identify if this client is Player 1 or Player 2