package com.tiedup.remake.dialogue.conversation;

/**
 * Enum defining requests that a pet (player) can make to their Master NPC.
 * This is the inverse of ConversationTopic - these are actions initiated by the player.
 *
 * Each request has:
 * - An ID for network serialization
 * - Display text shown in the menu
 * - Player speech text (what the player "says" when selecting)
 * - Response dialogue ID for the Master's response
 */
public enum PetRequest {
    /**
     * Ask Master for food. Triggers feeding sequence with bowl placement.
     */
    REQUEST_FOOD(
        "request.food",
        "Ask for food",
        "Please, may I have something to eat?",
        "petplay.feeding"
    ),

    /**
     * Ask Master to rest. Triggers resting sequence with pet bed placement.
     */
    REQUEST_SLEEP(
        "request.sleep",
        "Ask to rest",
        "I'm tired... may I rest?",
        "petplay.resting"
    ),

    /**
     * Request a walk where the pet leads (Master follows).
     */
    REQUEST_WALK_PASSIVE(
        "request.walk_passive",
        "Request a walk (you lead)",
        "Can we go for a walk? I'll lead the way.",
        "petplay.walk_passive"
    ),

    /**
     * Request a walk where the Master leads (Master walks, pulls pet).
     */
    REQUEST_WALK_ACTIVE(
        "request.walk_active",
        "Request a walk (Master leads)",
        "Can we go for a walk? You lead.",
        "petplay.walk_active"
    ),

    /**
     * Ask Master to tie you up.
     */
    REQUEST_TIE(
        "request.tie",
        "Ask to be tied",
        "Would you tie me up, please?",
        "petplay.tie_request"
    ),

    /**
     * Ask Master to untie you.
     */
    REQUEST_UNTIE(
        "request.untie",
        "Ask to be untied",
        "May I be untied, please?",
        "petplay.untie_request"
    ),

    /**
     * End the conversation gracefully.
     */
    END_CONVERSATION(
        "request.end",
        "End conversation",
        "Thank you, Master.",
        "petplay.dismiss"
    );

    private final String id;
    private final String displayText;
    private final String playerText;
    private final String responseDialogueId;

    PetRequest(
        String id,
        String displayText,
        String playerText,
        String responseDialogueId
    ) {
        this.id = id;
        this.displayText = displayText;
        this.playerText = playerText;
        this.responseDialogueId = responseDialogueId;
    }

    /**
     * Get the unique ID for this request (used in network packets).
     */
    public String getId() {
        return id;
    }

    /**
     * Get the display text shown in the request menu button.
     */
    public String getDisplayText() {
        return displayText;
    }

    /**
     * Get the text that represents what the player "says" when making this request.
     * This is displayed as player speech before the Master responds.
     */
    public String getPlayerText() {
        return playerText;
    }

    /**
     * Get the dialogue ID that the Master should respond with.
     */
    public String getResponseDialogueId() {
        return responseDialogueId;
    }

    /**
     * Find a PetRequest by its ID.
     *
     * @param id The request ID
     * @return The matching PetRequest, or null if not found
     */
    public static PetRequest fromId(String id) {
        for (PetRequest request : values()) {
            if (request.id.equals(id)) {
                return request;
            }
        }
        return null;
    }
}
