package thb.jeanluc.adventure.save;

import thb.jeanluc.adventure.io.ConsoleIO;
import thb.jeanluc.adventure.io.MusicLevel;

/** Persisted user preferences (colour + glyph fidelity + music level). */
public record Settings(ConsoleIO.ColorMode colorMode, ConsoleIO.GlyphMode glyphMode, MusicLevel musicLevel) {

    public Settings {
        if (colorMode == null) {
            colorMode = ConsoleIO.ColorMode.AUTO;
        }
        if (glyphMode == null) {
            glyphMode = ConsoleIO.GlyphMode.UNICODE;
        }
        if (musicLevel == null) {
            musicLevel = MusicLevel.MEDIUM; // backward-compat: old saves lack this field
        }
    }

    /** Backward-compatible constructor for callers that don't set music. */
    public Settings(ConsoleIO.ColorMode colorMode, ConsoleIO.GlyphMode glyphMode) {
        this(colorMode, glyphMode, MusicLevel.MEDIUM);
    }

    public static Settings defaults() {
        return new Settings(ConsoleIO.ColorMode.AUTO, ConsoleIO.GlyphMode.UNICODE, MusicLevel.MEDIUM);
    }
}
