package linea;

import javax.swing.JLabel;

public class GestionnaireFinDePartie {

    private boolean estGameOver = false;
    private JLabel labGameOver;
    private GestionnaireScore gestionnaireBDD;

    public GestionnaireFinDePartie(JLabel labGameOver, GestionnaireScore gestionnaireBDD) {
        this.labGameOver = labGameOver;
        this.gestionnaireBDD = gestionnaireBDD;
    }

    public void declencherGameOver(ZoneDessin ecran, String pseudo, int score) {
        estGameOver = true;
        ecran.arreter();
        labGameOver.setVisible(true);

        if (pseudo != null && !pseudo.isEmpty()) {
            gestionnaireBDD.sauvegarderScore(pseudo, score);
        }
    }

    public boolean estGameOver() {
        return estGameOver;
    }

    public void reinitialiser() {
        estGameOver = false;
        labGameOver.setVisible(false);
    }
}
