package com.tiedup.remake.compat.mca.personality;

/**
 * Maps MCA personality types to TiedUp behavior modifiers.
 *
 * <p>MCA 1.20.1 has these personalities:
 * ATHLETIC, CONFIDENT, FRIENDLY, FLIRTY, WITTY, SHY, GLOOMY,
 * SENSITIVE, GREEDY, ODD, LAZY, GRUMPY, PEPPY
 *
 * <p>Each personality affects:
 * <ul>
 *   <li>struggleMultiplier - How effectively they struggle against bonds</li>
 *   <li>complianceMultiplier - How quickly they accept restraints</li>
 *   <li>fleeSpeedMultiplier - How fast they flee/panic</li>
 *   <li>baseMoodTied - Mood change when tied (some like it!)</li>
 * </ul>
 */
public enum MCAPersonality {
    // Strong personalities - resist more
    ATHLETIC("athletic", 1.5f, 0.8f, 1.2f, -3),
    CONFIDENT("confident", 1.3f, 1.0f, 1.0f, -4),

    // Social personalities - more cooperative
    FRIENDLY("friendly", 0.7f, 1.2f, 0.8f, -2),
    FLIRTY("flirty", 0.5f, 1.5f, 0.6f, +2), // Enjoys it!

    // Clever but not strong
    WITTY("witty", 0.9f, 1.1f, 1.1f, -2),

    // Anxious personalities - panic more
    SHY("shy", 0.8f, 0.7f, 1.4f, -3),
    SENSITIVE("sensitive", 0.7f, 0.6f, 1.5f, -6),
    GLOOMY("gloomy", 0.6f, 0.8f, 0.9f, -4),

    // Special personalities
    GREEDY("greedy", 1.0f, 0.5f, 1.0f, -2), // Can be bribed
    ODD("odd", 1.1f, 1.0f, 1.2f, 0), // Unpredictable (mood is random)
    LAZY("lazy", 0.5f, 1.0f, 0.6f, 0), // Doesn't care much
    GRUMPY("grumpy", 1.2f, 0.3f, 0.7f, -3), // Resists, doesn't flee
    PEPPY("peppy", 1.0f, 1.2f, 1.3f, -1), // Energetic

    // Unknown/fallback
    UNKNOWN("unknown", 1.0f, 1.0f, 1.0f, -3);

    private final String mcaId;
    private final float struggleMultiplier;
    private final float complianceMultiplier;
    private final float fleeSpeedMultiplier;
    private final int baseMoodTied;

    MCAPersonality(
        String mcaId,
        float struggle,
        float compliance,
        float flee,
        int moodTied
    ) {
        this.mcaId = mcaId;
        this.struggleMultiplier = struggle;
        this.complianceMultiplier = compliance;
        this.fleeSpeedMultiplier = flee;
        this.baseMoodTied = moodTied;
    }

    public String getMcaId() {
        return mcaId;
    }

    /**
     * Get struggle effectiveness multiplier.
     * Higher = struggles more effectively against bonds.
     */
    public float getStruggleMultiplier() {
        return struggleMultiplier;
    }

    /**
     * Get compliance multiplier.
     * Higher = accepts restraints more easily (less resistance time).
     */
    public float getComplianceMultiplier() {
        return complianceMultiplier;
    }

    /**
     * Get flee/panic speed multiplier.
     * Higher = runs away faster when panicking.
     */
    public float getFleeSpeedMultiplier() {
        return fleeSpeedMultiplier;
    }

    /**
     * Get base mood change when tied.
     * Negative = unhappy, Positive = enjoys it.
     */
    public int getBaseMoodTied() {
        return baseMoodTied;
    }

    /**
     * Check if this personality generally enjoys being restrained.
     */
    public boolean enjoysBondage() {
        return baseMoodTied > 0;
    }

    /**
     * Check if this personality is unpredictable (ODD).
     */
    public boolean isUnpredictable() {
        return this == ODD;
    }

    /**
     * Find personality by MCA ID string (case-insensitive).
     *
     * @param id The MCA personality ID (e.g., "athletic", "shy")
     * @return The matching personality, or UNKNOWN if not found
     */
    public static MCAPersonality fromMcaId(String id) {
        if (id == null) return UNKNOWN;
        for (MCAPersonality p : values()) {
            if (p.mcaId.equalsIgnoreCase(id)) {
                return p;
            }
        }
        return UNKNOWN;
    }
}
