import { LitElement, html } from "lit"; import { customElement, property, state } from "lit/decorators.js"; import { PlayerGame } from "../../../../core/ApiSchemas"; import { GameMode } from "../../../../core/game/Game"; import { GameInfoModal } from "../../../GameInfoModal"; import { translateText } from "../../../Utils"; import "../../CopyButton"; @customElement("game-list") export class GameList extends LitElement { createRenderRoot() { return this; } @property({ type: Array }) games: PlayerGame[] = []; @property({ attribute: false }) onViewGame?: (id: string) => void; @state() private expandedGameId: string | null = null; private toggle(gameId: string) { this.expandedGameId = this.expandedGameId === gameId ? null : gameId; } private showRanking(gameId: string) { const gameInfoModal = document.querySelector( "game-info-modal", ) as GameInfoModal; if (!gameInfoModal) { console.warn("Game info modal element not found"); } else { gameInfoModal.loadGame(gameId); gameInfoModal.open(); } } render() { return html`
${this.games.map( (game) => html`
${new Date(game.start).toLocaleDateString()}
${translateText("game_list.mode")}: ${game.mode === GameMode.FFA ? translateText("game_mode.ffa") : html`${translateText("game_mode.teams")}`}
${translateText("game_list.game_id")}
${translateText("game_list.map")}
${game.map}
${translateText("game_list.difficulty")}
${game.difficulty}
${translateText("game_list.type")}
${game.type}
`, )}
`; } }