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

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;
import uk.mgrove.ac.soton.comp1206.game.Game;

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

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

    /**
     * Player's current score
     */
    private final Text score = new Text("0");
    /**
     * Player's current level
     */
    private final Text level = new Text("0");
    /**
     * Player's remaining lives
     */
    private final Text lives = new Text("3");
    /**
     * Player's current multiplier
     */
    private final Text multiplier = new Text("1");

    /**
     * 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());

        this.score.textProperty().bind(score.asString());
        this.level.textProperty().bind(level.asString());
        this.lives.textProperty().bind(lives.asString());
        this.multiplier.textProperty().bind(multiplier.asString());

        var scoreHeader = new Text("Score");
        var levelHeader = new Text("Level");
        var livesHeader = new Text("Lives");
        var multiplierHeader = new Text("Multiplier");
        getChildren().addAll(scoreHeader,this.score,levelHeader,this.level,livesHeader,this.lives,multiplierHeader,this.multiplier);
    }

}
