package gui.widget;

import game.Game;
import game.Player;
import imgui.ImGui;
import imgui.ImVec2;

public class MultiPlayerCompleteProgress {

	private final Game game;
	private final int emptyCellCount;
	private final ImVec2 progressSize = new ImVec2(700, 50);
	private final SmoothProgressBar progressBar;

	public MultiPlayerCompleteProgress(Game game) {
		this.game = game;
		this.emptyCellCount = game.getDoku().getEmptyCells().size();
		this.progressBar = new SmoothProgressBar();
	}

	public void render() {
		Player firstPlayer = game.getLeaderboard().getFirst();
		ImGui.setCursorPosX(ImGui.getIO().getDisplaySizeX() / 2.0f - progressSize.x / 2.0f);
		String progressText = firstPlayer.getPseudo() + " - " + (emptyCellCount - firstPlayer.getRemainingCells()) + "/" + emptyCellCount;
		this.progressBar.render(progressText, progressSize, 1.0f - firstPlayer.getRemainingCells() / (float) emptyCellCount);
	}

}
