package thb.jeanluc.adventure.io;

/** Background-music volume level, cycled in the Settings menu. */
public enum MusicLevel {
    OFF, LOW, MEDIUM, HIGH;

    /** Target MASTER_GAIN in decibels. Irrelevant for {@link #OFF} (playback disabled). */
    public float gainDb() {
        return switch (this) {
            case OFF -> Float.NEGATIVE_INFINITY;
            case LOW -> -20f;
            case MEDIUM -> -10f;
            case HIGH -> 0f;
        };
    }

    /** @return true when music should play. */
    public boolean isOn() {
        return this != OFF;
    }

    /** Next level in the cycle (wraps HIGH → OFF). */
    public MusicLevel next() {
        return values()[(ordinal() + 1) % values().length];
    }
}
