package com.tiedup.remake.v2;

import org.jetbrains.annotations.Nullable;

/**
 * V2 body region system with 14 regions and global/sub hierarchy.
 *
 * Global regions (HEAD, ARMS, LEGS) have sub-regions for organizational purposes.
 * Blocking is NOT automatic — each item declares which regions it blocks
 * via {@link IV2BondageItem#getBlockedRegions()}.
 */
public enum BodyRegionV2 {
    // Head regions
    HEAD(true),
    EYES(false),
    EARS(false),
    MOUTH(false),

    // Upper body
    NECK(false),
    TORSO(false),
    ARMS(true),
    HANDS(false),
    FINGERS(false),

    // Lower body
    WAIST(false),
    LEGS(true),
    FEET(false),

    // Special
    TAIL(false),
    WINGS(false);

    private final boolean global;

    BodyRegionV2(boolean global) {
        this.global = global;
    }

    /**
     * Whether this region is a global region that blocks sub-regions.
     */
    public boolean isGlobal() {
        return global;
    }

    /**
     * Safe valueOf that returns null instead of throwing on unknown names.
     */
    @Nullable
    public static BodyRegionV2 fromName(String name) {
        if (name == null) return null;
        try {
            return valueOf(name);
        } catch (IllegalArgumentException e) {
            return null;
        }
    }
}
