package com.tiedup.remake.dialogue;

import com.tiedup.remake.personality.PersonalityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.Nullable;

/**
 * Interface for entities that can speak dialogue.
 * Implemented by all NPCs that use the data-driven dialogue system.
 *
 * Dialogue System: Universal NPC dialogue support
 */
public interface IDialogueSpeaker {
    /**
     * Get the name displayed in dialogue chat messages.
     *
     * @return The speaker's display name
     */
    String getDialogueName();

    /**
     * Get the speaker type for dialogue routing.
     * Determines which dialogue folder is used.
     *
     * @return The speaker type
     */
    SpeakerType getSpeakerType();

    /**
     * Get the speaker's personality for dialogue selection.
     * May return null for NPCs without a personality system.
     *
     * @return PersonalityType or null
     */
    @Nullable
    PersonalityType getSpeakerPersonality();

    /**
     * Get the speaker's current mood (0-100).
     * 50 = neutral, higher = happier, lower = angrier.
     *
     * @return Mood value between 0 and 100
     */
    int getSpeakerMood();

    /**
     * Get the relation type between this speaker and a player.
     * Used for dialogue condition matching.
     *
     * Examples:
     * - "master" (player owns this NPC)
     * - "captor" (kidnapper holding player)
     * - "prisoner" (player is imprisoned by this NPC's camp)
     * - "customer" (player is trading with this NPC)
     * - null (no special relation)
     *
     * @param player The player to check relation with
     * @return Relation type string or null
     */
    @Nullable
    String getTargetRelation(Player player);

    /**
     * Get this speaker as a LivingEntity.
     * Used for getting position, level, and other entity data.
     *
     * @return The entity implementing this interface
     */
    LivingEntity asEntity();

    /**
     * Get a cooldown timer to prevent dialogue spam.
     * Returns 0 if dialogue is allowed now.
     *
     * @return Remaining cooldown ticks (0 = can speak)
     */
    default int getDialogueCooldown() {
        return 0;
    }

    /**
     * Set the dialogue cooldown timer.
     *
     * @param ticks Cooldown duration in ticks
     */
    default void setDialogueCooldown(int ticks) {
        // Default: no-op, override in implementations that track cooldown
    }

    /**
     * Check if dialogue should be processed through gag filter.
     * For gagged entities, dialogue text is muffled.
     *
     * @return true if speaker is gagged
     */
    default boolean isDialogueGagged() {
        return false;
    }
}
