package com.tiedup.remake.prison;

/**
 * Simplified prisoner state enum.
 *
 * Replaces the complex 9-state CaptivityStateEnum with 5 clear states.
 * All "in-cell" sub-states (IDLE, PENDING, RESTING) are consolidated into IMPRISONED.
 * ESCAPED state is removed - escaped prisoners go straight to FREE.
 */
public enum PrisonerState {
    /**
     * Player is not captured and not under protection.
     * Can be targeted by kidnappers normally.
     */
    FREE(false, false, false),

    /**
     * Player has been captured and is being transported by a kidnapper.
     * Cannot be retargeted by other kidnappers.
     */
    CAPTURED(true, false, true),

    /**
     * Player is in a cell.
     * This consolidates the old IDLE, PENDING, RESTING states.
     * The specific sub-state is tracked via MaidWorkPhase in LaborRecord.
     */
    IMPRISONED(true, false, true),

    /**
     * Player has been extracted from cell and is actively working on a task.
     * Includes both the working phase and the returning phase.
     */
    WORKING(true, false, true),

    /**
     * Player has been released with temporary protection.
     * Cannot be targeted by kidnappers until protection expires.
     * Duration: 5 minutes (6000 ticks).
     */
    PROTECTED(false, true, false);

    private final boolean imprisoned;
    private final boolean protected_;
    private final boolean captive;

    PrisonerState(boolean imprisoned, boolean protected_, boolean captive) {
        this.imprisoned = imprisoned;
        this.protected_ = protected_;
        this.captive = captive;
    }

    /**
     * @return true if player is in any imprisonment state (in cell or working)
     */
    public boolean isImprisoned() {
        return imprisoned;
    }

    /**
     * @return true if player is protected from being captured/recaptured
     */
    public boolean isProtected() {
        return protected_;
    }

    /**
     * @return true if player is under active captivity (being transported or imprisoned)
     */
    public boolean isCaptive() {
        return captive;
    }

    /**
     * @return true if player can be targeted by kidnappers
     */
    public boolean isTargetable() {
        return this == FREE;
    }

    /**
     * @return true if player is in a cell (IMPRISONED state)
     */
    public boolean isInCell() {
        return this == IMPRISONED;
    }

    /**
     * @return true if player is actively working
     */
    public boolean isWorking() {
        return this == WORKING;
    }
}
