import { client, navigateTo } from "../index.js"; import AbstractView from "./abstracts/AbstractView.js"; function game_found(game_id) { navigateTo(`/games/${game_id}`) } export default class extends AbstractView { constructor(params) { super(params, "Matchmaking"); } async press_button() { if (client.matchmaking.searching) { client.matchmaking.stop(); document.getElementById("button").value = "Find a game" } else { await this.matchmaking(); document.getElementById("button").value = "Stop matchmaking" } } async matchmaking() { let nb_players = document.getElementById("nb_players-input").value client.matchmaking.start(game_found, nb_players); } async postInit() { document.getElementById("button").onclick = this.matchmaking } async getHtml() { return `