package uk.mgrove.ac.soton.comp1206.component;

import javafx.beans.property.IntegerProperty;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * Stats menu class to show basic stats about game status
 */
public class StatsMenu extends VBox {

    /**
     * Logger
     */
    private static final Logger logger = LogManager.getLogger(StatsMenu.class);

    /**
     * Initialise the menu by adding basic stats and binding them to properties
     * @param score score property
     * @param level level property
     * @param lives lives property
     * @param multiplier multiplier property
     */
    public StatsMenu(IntegerProperty score, IntegerProperty level, IntegerProperty lives, IntegerProperty multiplier) {
        logger.info("Initialising new stats menu with score {}, level {}, lives {}, and multiplier {}", score.get(), level.get(), lives.get(), multiplier.get());

        Text score1 = new Text();
        score1.textProperty().bind(score.asString());
        score1.getStyleClass().add("score");
        Text level1 = new Text();
        level1.textProperty().bind(level.asString());
        level1.getStyleClass().add("level");
        Text lives1 = new Text();
        lives1.textProperty().bind(lives.asString());
        lives1.getStyleClass().add("lives");
        Text multiplier1 = new Text();
        multiplier1.textProperty().bind(multiplier.asString());
        multiplier1.getStyleClass().add("level");

        var scoreHeader = new Text("Score");
        var levelHeader = new Text("Level");
        var livesHeader = new Text("Lives");
        var multiplierHeader = new Text("Multiplier");

        getChildren().addAll(new VBox(scoreHeader, score1),new VBox(livesHeader, lives1),new VBox(levelHeader, level1),new VBox(multiplierHeader, multiplier1));
        setSpacing(8);
    }

}
