package com.red.circle.other.domain.enums;

/**
 * VIP 布尔权限类型.
 * 各等级顺序: VIP1(VISCOUNT) ~ VIP6(EMPEROR)
 */
public enum VipAbilityType {

    /** 拒绝陌生人联系 */
    BLOCK_STRANGERS(false, false, false, true, true, true),

    /** 免费创建家族 */
    CREATE_FAMILY_FREE(false, false, false, true, true, true),

    /** 防踢 */
    KICK_PREVENTION(false, false, false, false, true, true),

    /** 防拉黑 */
    ANTI_BLOCK(false, false, false, false, false, true),

    /** 神秘隐身 */
    MYSTERIOUS_INVISIBILITY(false, false, false, false, false, true);

    // index 0~5 = VIP1~VIP6
    private final boolean[] levels;

    VipAbilityType(boolean... levels) {
        this.levels = levels;
    }

    /**
     * 根据 VIP name 判断是否拥有该权限，非VIP或未匹配返回 false.
     */
    public boolean hasAbility(String vipName) {
        if (vipName == null) {
            return false;
        }
        switch (vipName) {
            case "VISCOUNT": return levels[0];
            case "EARL":     return levels[1];
            case "MARQUIS":  return levels[2];
            case "DUKE":     return levels[3];
            case "KING":     return levels[4];
            case "EMPEROR":  return levels[5];
            default:         return false;
        }
    }
}
