package com.tiedup.remake.entities.ai.master;

/**
 * Enum defining the behavioral states of a Master entity.
 *
 * Master NPC follows a different pattern than Kidnapper:
 * - FOLLOWING: Master follows their pet (player)
 * - OBSERVING: Master is watching the pet (can detect struggle)
 * - DISTRACTED: Master is distracted (pet can struggle safely)
 * - TASK_ASSIGN: Master is assigning a task to pet
 * - TASK_WATCH: Master is watching pet perform a task
 * - INSPECT: Master is inspecting pet's inventory for contraband
 * - PUNISH: Master is punishing pet for misbehavior
 * - PURCHASING: Master is buying a pet from a Kidnapper
 */
public enum MasterState {
    /**
     * Idle state - Master has nothing specific to do.
     * Default state when no other action is available.
     */
    IDLE,

    /**
     * Purchasing state - Master is buying a captive from a Kidnapper.
     * This is the initial state when Master spawns.
     */
    PURCHASING,

    /**
     * Following state - Master follows the pet player.
     * Unlike normal NPCs, the Master follows the player, not vice versa.
     * Maintains 2-8 block distance.
     */
    FOLLOWING,

    /**
     * Observing state - Master is actively watching the pet.
     * Can detect struggle attempts in this state.
     * Pet cannot escape while being observed.
     */
    OBSERVING,

    /**
     * Distracted state - Master is temporarily distracted.
     * Pet can safely struggle in this state.
     * Lasts 30-60 seconds, occurs every 2-5 minutes.
     */
    DISTRACTED,

    /**
     * Task assign state - Master is assigning a task to the pet.
     * Transitions to TASK_WATCH after assignment.
     */
    TASK_ASSIGN,

    /**
     * Task watch state - Master is supervising pet's task execution.
     * Similar to OBSERVING but focused on task completion.
     */
    TASK_WATCH,

    /**
     * Inspect state - Master is checking pet's inventory for contraband.
     * Will confiscate lockpicks, knives, weapons, etc.
     */
    INSPECT,

    /**
     * Punish state - Master is punishing the pet.
     * Uses shock collar, paddle, or other punishment methods.
     * Triggered by: struggle detected, task failed, contraband found.
     */
    PUNISH,

    /**
     * Dogwalk state - Master is taking pet on a walk (event).
     * Similar to FOLLOWING but with specific destination.
     */
    DOGWALK,

    /**
     * Human Chair state - Master uses pet as furniture.
     * Pet is forced on all fours, cannot move. Master sits on pet.
     * Lasts ~2 minutes with idle dialogue.
     */
    HUMAN_CHAIR;

    /**
     * Check if this state allows the master to detect struggles.
     * OBSERVING, TASK_WATCH, and FOLLOWING can detect struggles.
     */
    public boolean canDetectStruggle() {
        return this == OBSERVING || this == TASK_WATCH || this == FOLLOWING;
    }

    /**
     * Check if this state is a "watching" state where Master pays attention.
     */
    public boolean isWatching() {
        return this == OBSERVING || this == TASK_WATCH || this == INSPECT;
    }

    /**
     * Check if this state allows the pet to struggle without detection.
     */
    public boolean allowsSafeStruggle() {
        return this == DISTRACTED || this == IDLE;
    }

    /**
     * Check if Master can transition to punishment from this state.
     */
    public boolean canTransitionToPunish() {
        return this != PUNISH && this != PURCHASING;
    }

    /**
     * Check if Master is actively engaged with pet (not idle).
     */
    public boolean isEngaged() {
        return this != IDLE && this != DISTRACTED;
    }
}
