package gui.menu;

import gui.SudokuRenderer;
import imgui.ImGui;
import network.client.Client;
import network.server.Server;

public class MultiPlayerDokuView extends BaseView{

	private final Client client;
	private final Server server;
	private final SudokuRenderer sudokuRenderer;

	public MultiPlayerDokuView(StateMachine stateMachine, Client client, Server server) {
		super(stateMachine);
		this.client = client;
		this.server = server;
		this.sudokuRenderer = new SudokuRenderer(this.client.getGame().getDoku());
		this.client.onDisconnect.connect(this::onDisconnect);
	}

	public void onDisconnect() {
		if (server == null) {
			closeMenu();
		}
	}

	@Override
	public void render() {
		this.sudokuRenderer.render();
		if (ImGui.button("Quitter")) {
			this.client.stop();
			this.closeMenu(3);
		}
	}

}
