package com.openosrs.client.login;

/**
 * LoginState - Represents the current state of the login process.
 * 
 * This enum tracks the progression through the automated login sequence,
 * allowing agents to monitor and respond to login status changes.
 */
public enum LoginState {
    /**
     * Client is not connected to any game servers.
     */
    DISCONNECTED("Disconnected"),
    
    /**
     * Attempting to establish connection to RuneScape servers.
     */
    CONNECTING("Connecting to servers"),
    
    /**
     * Choosing the optimal world for gameplay.
     */
    SELECTING_WORLD("Selecting world"),
    
    /**
     * Sending authentication credentials to the server.
     */
    AUTHENTICATING("Authenticating"),
    
    /**
     * Verifying successful login and game state.
     */
    VALIDATING("Validating login"),
    
    /**
     * Successfully logged in and ready for gameplay.
     */
    LOGGED_IN("Logged in"),
    
    /**
     * In the process of disconnecting from the game.
     */
    DISCONNECTING("Disconnecting"),
    
    /**
     * Login process failed - check error details.
     */
    FAILED("Login failed"),
    
    /**
     * Attempting to reconnect after disconnection.
     */
    RECONNECTING("Reconnecting");
    
    private final String description;
    
    LoginState(String description) {
        this.description = description;
    }
    
    /**
     * Get a human-readable description of this login state.
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * Check if this state represents a connected/active state.
     */
    public boolean isConnected() {
        return this == LOGGED_IN;
    }
    
    /**
     * Check if this state represents a transitional/in-progress state.
     */
    public boolean isInProgress() {
        return this == CONNECTING || 
               this == SELECTING_WORLD || 
               this == AUTHENTICATING || 
               this == VALIDATING ||
               this == DISCONNECTING ||
               this == RECONNECTING;
    }
    
    /**
     * Check if this state represents a failure state.
     */
    public boolean isFailed() {
        return this == FAILED;
    }
    
    @Override
    public String toString() {
        return description;
    }
}