package com.tiedup.remake.entities;

import com.tiedup.remake.entities.skins.Gender;
import com.tiedup.remake.entities.skins.SkinVariant;
import net.minecraft.resources.ResourceLocation;

/**
 * Represents a kidnapper skin variant with metadata.
 *
 * All skins from kidnapper folder, random selection.
 *
 * @param id Unique identifier (e.g., "knp_mob_1", "blake")
 * @param texture Skin texture location
 * @param hasSlimArms True for Alex/slim model (3px arms), false for Steve/normal (4px arms)
 * @param defaultName Default display name for this variant
 * @param gender Gender of the skin (default FEMALE)
 */
public record KidnapperVariant(
    String id,
    ResourceLocation texture,
    boolean hasSlimArms,
    String defaultName,
    Gender gender
) implements SkinVariant {
    /**
     * Create a kidnapper variant from texture name.
     *
     * @param textureName Texture file name without extension (e.g., "knp_mob_1", "blake")
     * @param hasSlimArms True if this variant uses slim arms
     * @return Kidnapper variant
     */
    public static KidnapperVariant create(
        String textureName,
        boolean hasSlimArms
    ) {
        return create(textureName, hasSlimArms, "Kidnapper");
    }

    /**
     * Create a kidnapper variant from texture name with custom display name.
     *
     * @param textureName Texture file name without extension
     * @param hasSlimArms True if this variant uses slim arms
     * @param displayName Display name for this variant
     * @return Kidnapper variant
     */
    public static KidnapperVariant create(
        String textureName,
        boolean hasSlimArms,
        String displayName
    ) {
        return new KidnapperVariant(
            textureName,
            ResourceLocation.fromNamespaceAndPath(
                "tiedup",
                "textures/entity/kidnapper/" + textureName + ".png"
            ),
            hasSlimArms,
            displayName,
            Gender.FEMALE
        );
    }

    /**
     * Create a variant with a custom texture subfolder.
     * Used by MaidSkinManager, TraderSkinManager, etc.
     *
     * @param textureName   Texture file name without extension
     * @param subfolder     Subfolder under kidnapper/ (e.g., "maid", "trader")
     * @param hasSlimArms   True if this variant uses slim arms
     * @param displayName   Display name for this variant (required)
     * @param gender        Gender of the variant
     * @return Kidnapper variant
     */
    public static KidnapperVariant createWithSubfolder(
        String textureName,
        String subfolder,
        boolean hasSlimArms,
        String displayName,
        Gender gender
    ) {
        return new KidnapperVariant(
            textureName,
            ResourceLocation.fromNamespaceAndPath(
                "tiedup",
                "textures/entity/kidnapper/" +
                    subfolder +
                    "/" +
                    textureName +
                    ".png"
            ),
            hasSlimArms,
            displayName,
            gender
        );
    }

    @Override
    public String toString() {
        return (
            "KidnapperVariant{id='" +
            id +
            "', slim=" +
            hasSlimArms +
            ", name='" +
            defaultName +
            "', gender=" +
            gender +
            "}"
        );
    }
}
