package eu.jonahbauer.wizard.client.libgdx.util;

import com.badlogic.gdx.audio.Sound;
import lombok.Setter;

public class SoundManager {
    public static final float CARD_SHUFFLE_DURATION = 4.2f;

    private final WizardAssetManager assets;

    @Setter
    private float sfxVolume = 1;

    private final Sound click;
    private final Sound cardPlayed;
    private final Sound cardShuffle;

    public SoundManager(WizardAssetManager assets) {
        this.assets = assets;
        assets.load(WizardAssetManager.SFX_CLICK, Sound.class);
        assets.load(WizardAssetManager.SFX_CARD_PLAYED, Sound.class);
        assets.load(WizardAssetManager.SFX_CARD_SHUFFLE, Sound.class);
        assets.finishLoading();

        this.click = assets.get(WizardAssetManager.SFX_CLICK);
        this.cardPlayed = assets.get(WizardAssetManager.SFX_CARD_PLAYED);
        this.cardShuffle = assets.get(WizardAssetManager.SFX_CARD_SHUFFLE);
    }

    public void sfxClick() {
        this.click.play(sfxVolume);
    }

    public void sfxShuffle() {
        this.cardShuffle.play(sfxVolume);
    }

    public void sfxPlayCard() {
        this.cardPlayed.play(sfxVolume);
    }

    public void dispose() {
        assets.unload(WizardAssetManager.SFX_CLICK);
        assets.unload(WizardAssetManager.SFX_CARD_PLAYED);
        assets.unload(WizardAssetManager.SFX_CARD_SHUFFLE);
    }
}
