add: TicTacToe online view

This commit is contained in:
Namonay
2024-03-22 16:26:37 +01:00
parent e633c4eaff
commit a0b105a75b
3 changed files with 30 additions and 11 deletions

View File

@ -20,8 +20,7 @@ export default class extends AbstractAuthenticatedView {
else
{
let nb_players = this.input.value;
await client.matchmaking.start(this.onreceive.bind(this), this.ondisconnect.bind(this), nb_players);
await client.matchmaking.start(this.onreceive.bind(this), this.ondisconnect.bind(this), nb_players, this.gamemode);
this.button.innerHTML = lang.get("matchmakingStopSearch");
}
@ -36,7 +35,10 @@ export default class extends AbstractAuthenticatedView {
{
if (data.detail === "game_found")
{
navigateTo(`/games/${data.game_id}`);
if (this.gamemode.value == "pong")
navigateTo(`/games/${data.game_id}`);
else
navigateTo(`/games/${this.gamemode.value}/${data.game_id}`);
return;
}
this.display_data(data);
@ -52,7 +54,8 @@ export default class extends AbstractAuthenticatedView {
{
this.button = document.getElementById("toggle-search");
this.input = document.getElementById("nb-players-input");
this.gamemode = document.getElementById("game-choice");
let container = document.getElementById("nb-players-container");
let gameChoice = document.getElementById("game-choice");
@ -68,7 +71,7 @@ export default class extends AbstractAuthenticatedView {
gameChoice.addEventListener("change", function()
{
if (this.value === "TicTacToe")
if (this.value === "tictactoe")
{
container.style.display = 'none';
document.getElementById("nb-players-input").value = 2;
@ -94,8 +97,8 @@ export default class extends AbstractAuthenticatedView {
<div>
<div class='form-floating mb-2'>
<select class='form-control' id='game-choice'>
<option value='Pong'>Pong</option>
<option value='TicTacToe'>TicTacToe</option>
<option value='pong'>Pong</option>
<option value='tictactoe'>ticTacToe</option>
</select>
<label for='game-choice'>${lang.get("gamemodeChoice")}</label>
</div>