package com.mygdx.game;

public class UIUpdater {
    public static void updateUI(AbsurdCityBuilder1 game) {
        if (game.getGameState() != GameState.PLAYING) {
            return;
        }

        Planet planet = game.getCurrentPlanet();

        if (game.getCurrentBuilding() != null && game.getCurrentProblem() != null) {
            String overlapText = game.getCurrentBuilding().isOverlapping ? " " + Localization.overlapping() : "";
            String colorInfo = "";
            if (game.getCurrentBuilding().isComplete()) {
                colorInfo = String.format(" [%s %d]", Localization.colorTheme(), game.getCurrentBuilding().colorThemeIndex + 1);
            }
            String fullText = Localization.building() + " " + Localization.getBuildingName(game.getCurrentBuilding()) +
                " (" + game.getCurrentBuilding().constructionProgress + "/3)" + colorInfo +
                ": " + game.getCurrentProblem().getQuestion() + overlapText;
            game.setProblemText(fullText);
        } else {
            String planetText = game.isSwitchingPlanets() ?
                Localization.flyingTo() + " " + Localization.planetName(game.getTargetPlanet()) + "..." :
                Localization.planet() + ": " + Localization.planetName(planet);

            game.setProblemText(planetText +
                " | " + Localization.buildingType() + ": " + Localization.getBuildingName(planet, game.getSelectedBuildingType()) +
                " " + Localization.arrowsToSelect() +
                " | ESC - " + Localization.menu());
        }
    }
}
