(tic-tac-toe): Added history button to check player's tic-tac-toe matches history
This commit is contained in:
parent
5eec958663
commit
deb391807a
3 changed files with 17 additions and 5 deletions
|
|
@ -82,3 +82,8 @@
|
|||
font-bold
|
||||
hover:bg-gray-500
|
||||
}
|
||||
|
||||
#historyBtn {
|
||||
@apply
|
||||
text-white
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<div class="displaybox">
|
||||
<div class="mainboxDisplay" id="mainbox">
|
||||
<button class="btn-style absolute top-4 left-6" id="historyBtn">History</button>
|
||||
<button class="btn-style absolute top-4 right-6" id="JoinQueueBtn">Join Queue</button>
|
||||
<h1 class="text-3xl font-bold text-gray-800">
|
||||
Tic-tac-toe Box<span id="t-username"></span>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import "./ttt.css"
|
||||
import {addRoute, setTitle, type RouteHandlerReturn} from "@app/routing";
|
||||
import {addRoute, setTitle, navigateTo, type RouteHandlerReturn} from "@app/routing";
|
||||
import tttPage from "./ttt.html?raw";
|
||||
import {showError, showInfo} from "@app/toast";
|
||||
import {io} from "socket.io-client";
|
||||
|
|
@ -54,13 +54,14 @@ async function handleTTT(): Promise<RouteHandlerReturn> {
|
|||
if (user === null)
|
||||
return;
|
||||
|
||||
const userXString = document.getElementById("playerX-name");
|
||||
const userOString = document.getElementById("playerO-name");
|
||||
const currentPlayerIndicator = document.getElementById("currentPlayer");
|
||||
const currentPlayerTimer = document.getElementById("currentPlayerTimer");
|
||||
const historyButton = document.getElementById("historyBtn");
|
||||
const joinQueueBtn = document.getElementById("JoinQueueBtn");
|
||||
const currentPlayerTimer = document.getElementById("currentPlayerTimer")
|
||||
const result_message = document.getElementById("ttt-end-screen");
|
||||
if (!userXString || !userOString || !currentPlayerIndicator || !joinQueueBtn || !currentPlayerTimer || !result_message) {
|
||||
const userOString = document.getElementById("playerO-name");
|
||||
const userXString = document.getElementById("playerX-name");
|
||||
if (!currentPlayerIndicator || !currentPlayerTimer || !historyButton || !joinQueueBtn || !result_message || !userOString || !userXString) {
|
||||
return showError('fatal error');
|
||||
}
|
||||
|
||||
|
|
@ -79,6 +80,11 @@ async function handleTTT(): Promise<RouteHandlerReturn> {
|
|||
socket.emit("enqueue");
|
||||
});
|
||||
|
||||
//TODO: Redirect to /app/ttt
|
||||
historyButton.addEventListener("click", () => {
|
||||
navigateTo("/app/ttt/games");
|
||||
});
|
||||
|
||||
let curGame: CurrentGameInfo | null = null;
|
||||
let curGameX: { id: string, name: string } | null = null;
|
||||
let curGameO: { id: string, name: string } | null = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue