Package com.ohacd.matchbox.api
Class PhaseController
java.lang.Object
com.ohacd.matchbox.api.PhaseController
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
ConstructorsConstructorDescriptionPhaseController(@NotNull com.ohacd.matchbox.game.session.GameSession session) Creates a new phase controller for the specified session. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanTransitionTo(@NotNull com.ohacd.matchbox.game.utils.GamePhase targetPhase) Checks if transitioning to a specific phase is valid.booleanforcePhase(@NotNull com.ohacd.matchbox.game.utils.GamePhase targetPhase) Forces the game to a specific phase.@Nullable com.ohacd.matchbox.game.utils.GamePhaseGets the current game phase.@NotNull StringGets a description of the current phase state.longGets the estimated time remaining in the current phase.booleanSkips to the next phase in the natural progression.toString()
-
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
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
-