package com.mygdx.game;

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

        Planet planet = game.getCurrentPlanet();
        String[] planetBuildings = Building.BUILDING_TYPES_BY_PLANET[planet.ordinal()];

        if (game.getCurrentBuilding() != null && game.getCurrentProblem() != null) {
            String overlapText = game.getCurrentBuilding().isOverlapping ? " (пересекается!)" : "";
            String colorInfo = "";
            if (game.getCurrentBuilding().isComplete()) {
                colorInfo = String.format(" [Цвет: Тема %d]", game.getCurrentBuilding().colorThemeIndex + 1);
            }
            String fullText = "Строим " + game.getCurrentBuilding().type +
                " (" + game.getCurrentBuilding().constructionProgress + "/3)" + colorInfo +
                ": " + game.getCurrentProblem().getQuestion() + overlapText;
            game.setProblemText(fullText);
        } else {
            String planetText = game.isSwitchingPlanets() ?
                "Перелет на " + game.getTargetPlanet().getName() + "..." :
                "Планета: " + planet.getName();

            game.setProblemText(planetText +
                " | Тип здания: " + planetBuildings[game.getSelectedBuildingType()] +
                " (←/→ для выбора, кликните на поле для строительства)" +
                " | ESC - меню");
        }
    }
}
