package com.tiedup.remake.dialogue.conversation;

/**
 * Reasons why an NPC might refuse to engage in conversation.
 * Each reason has a corresponding dialogue ID for personality-specific responses.
 *
 */
public enum ConversationRefusalReason {
    /** No refusal - NPC will talk */
    NONE("", false),

    /** Cooldown active - recently finished talking */
    COOLDOWN("conversation.refusal.cooldown", false),

    /** Mood too low (< 20) - not feeling talkative */
    LOW_MOOD("conversation.refusal.low_mood", true),

    /** Resentment too high (> 70) - silent treatment */
    HIGH_RESENTMENT("conversation.refusal.resentment", true),

    /** Fear too high (> 60) - too scared to talk */
    FEAR_OF_PLAYER("conversation.refusal.fear", true),

    /** Rest too low (< 20) - too exhausted to talk */
    EXHAUSTED("conversation.refusal.exhausted", true),

    /** Topic limit reached - tired of talking this session */
    TOPIC_LIMIT("conversation.refusal.tired", true);

    /** Dialogue ID for the refusal message (personality-specific) */
    private final String dialogueId;

    /** Whether this refusal can be shown to the player as a message */
    private final boolean hasDialogue;

    ConversationRefusalReason(String dialogueId, boolean hasDialogue) {
        this.dialogueId = dialogueId;
        this.hasDialogue = hasDialogue;
    }

    /**
     * Get the dialogue ID for this refusal reason.
     * Used to fetch personality-specific refusal messages.
     *
     * @return Dialogue ID string
     */
    public String getDialogueId() {
        return dialogueId;
    }

    /**
     * Whether this refusal has associated dialogue.
     *
     * @return true if there's a dialogue response
     */
    public boolean hasDialogue() {
        return hasDialogue;
    }

    /**
     * Get the translation key for the reason (for UI display).
     *
     * @return Translation key
     */
    public String getTranslationKey() {
        return "conversation.refusal." + this.name().toLowerCase();
    }

    /**
     * Get how long (in ticks) before the player can try again.
     * Returns 0 for reasons that aren't time-based.
     *
     * @return Retry delay in ticks, or 0
     */
    public int getRetryDelay() {
        return switch (this) {
            case COOLDOWN -> 1200; // 1 minute cooldown in ticks
            case TOPIC_LIMIT -> 200; // 10 seconds
            default -> 0; // State-based, no fixed delay
        };
    }

    /**
     * Get a suggestion for the player on how to resolve this refusal.
     *
     * @return Translation key for the suggestion
     */
    public String getSuggestionKey() {
        return switch (this) {
            case COOLDOWN -> "conversation.suggestion.wait";
            case LOW_MOOD -> "conversation.suggestion.improve_mood";
            case HIGH_RESENTMENT -> "conversation.suggestion.reduce_resentment";
            case FEAR_OF_PLAYER -> "conversation.suggestion.be_gentle";
            case EXHAUSTED -> "conversation.suggestion.let_rest";
            case TOPIC_LIMIT -> "conversation.suggestion.end_conversation";
            default -> "";
        };
    }
}
