Class PhaseController

java.lang.Object
com.ohacd.matchbox.api.PhaseController

public final class PhaseController extends Object
Utility class for managing game phases with simplified operations.

This class provides a clean interface for phase control operations, abstracting away the complexity of direct phase manipulation.

Example usage:


 PhaseController controller = new PhaseController(session);
 
 // Skip to next phase
 boolean success = controller.skipToNextPhase();
 
 // Force specific phase
 success = controller.forcePhase(GamePhase.DISCUSSION);
 
 // Check if phase transition is valid
 boolean canTransition = controller.canTransitionTo(GamePhase.VOTING);
 
Since:
0.9.5
  • Constructor Summary

    Constructors
    Constructor
    Description
    PhaseController(@NotNull com.ohacd.matchbox.game.session.GameSession session)
    Creates a new phase controller for the specified session.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canTransitionTo(@NotNull com.ohacd.matchbox.game.utils.GamePhase targetPhase)
    Checks if transitioning to a specific phase is valid.
    boolean
    forcePhase(@NotNull com.ohacd.matchbox.game.utils.GamePhase targetPhase)
    Forces the game to a specific phase.
    @Nullable com.ohacd.matchbox.game.utils.GamePhase
    Gets the current game phase.
    @NotNull String
    Gets a description of the current phase state.
    long
    Gets the estimated time remaining in the current phase.
    boolean
    Skips to the next phase in the natural progression.
     

    Methods inherited from class java.lang.Object

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

    • PhaseController

      public PhaseController(@NotNull @NotNull com.ohacd.matchbox.game.session.GameSession session)
      Creates a new phase controller for the specified session.
      Parameters:
      session - the game session to control
      Throws:
      IllegalArgumentException - if session is null
  • Method Details

    • getCurrentPhase

      @Nullable public @Nullable com.ohacd.matchbox.game.utils.GamePhase getCurrentPhase()
      Gets the current game phase.
      Returns:
      the current phase, or null if not available
    • skipToNextPhase

      public boolean skipToNextPhase()
      Skips to the next phase in the natural progression.
      Returns:
      true if the phase was skipped successfully
    • forcePhase

      public boolean forcePhase(@NotNull @NotNull com.ohacd.matchbox.game.utils.GamePhase targetPhase)
      Forces the game to a specific phase.
      Parameters:
      targetPhase - the phase to force
      Returns:
      true if the phase was forced successfully
    • canTransitionTo

      public boolean canTransitionTo(@NotNull @NotNull com.ohacd.matchbox.game.utils.GamePhase targetPhase)
      Checks if transitioning to a specific phase is valid.
      Parameters:
      targetPhase - the phase to check
      Returns:
      true if the transition is valid
    • getPhaseDescription

      @NotNull public @NotNull String getPhaseDescription()
      Gets a description of the current phase state.
      Returns:
      human-readable phase description
    • getTimeRemaining

      public long getTimeRemaining()
      Gets the estimated time remaining in the current phase.
      Returns:
      estimated seconds remaining, or -1 if not available
    • toString

      public String toString()
      Overrides:
      toString in class Object