add: tictactoe: timers on catchup

This commit is contained in:
Namonay
2024-05-14 16:46:16 +02:00
parent aa01405988
commit 995a808974
5 changed files with 50 additions and 25 deletions

View File

@ -86,8 +86,7 @@ export default class extends AbstractView {
games.forEach(game => {
if (game.finished === false)
return
if (this.profile.id === game.winner.id)
if (this.profile.id === game.winner?.id)
win++;
else
lose++;
@ -114,10 +113,16 @@ export default class extends AbstractView {
let game_item = document.createElement("div");
game_item.className = "game-item";
game_item.style.backgroundColor = "grey";
if (game.started)
game_item.style.backgroundColor = "yellow";
if (game.finished)
if (game.finished && game.winner == null)
game_item.style.backgroundColor = "red";
else if (game.finished)
game_item.style.backgroundColor = this.profile.id === game.winner.id ? "green" : "red";
else if (game.started)
game_item.style.backgroundColor = "yellow";
let gametype = document.createElement("b");
gametype.innerText = `${(game.game_type == "tictactoe") ? lang.get("ticTacToeTitle") : "Pong"}`;
game_item.appendChild(gametype);
game.players.forEach(player => {
let player_score = document.createElement("a");
@ -128,7 +133,6 @@ export default class extends AbstractView {
game_item.appendChild(player_score);
});
a.appendChild(game_item);
game_list.appendChild(a);
});

View File

@ -1,12 +1,12 @@
import AbstractView from "./abstracts/AbstractView.js";
import { lang } from "../index.js";
import { TicTacToe } from "../api/game/tictactoe/TicTacToeGame.js"
export class TicTacToeOnlineView extends AbstractView
import AbstractAuthenticatedView from "./abstracts/AbstractAuthenticatedView.js";
import { navigateTo } from "../index.js"
export class TicTacToeOnlineView extends AbstractAuthenticatedView
{
constructor(params, titleKey)
{
super(params, lang.get('ticTacToeTitle'));
super(params, 'ticTacToeTitle');
this.params = params;
this.titleKey = titleKey;
this.game_id = params.id;