Skip to content

Commit

Permalink
Fix white/black labels in live games
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavNikolov committed Aug 22, 2023
1 parent 555aad1 commit 04e1c1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/canvas-chess-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class CanvasChessRenderer {
this.ctx.fillStyle = '#eedab8';
for(let row = 0;row < 8; row ++) {
for(let col = 0;col < 8; col ++) {
if(row % 2 !== col % 2) continue;
if(row % 2 === col % 2) continue;
this.ctx.fillRect(col * drawSize, row * drawSize, drawSize, drawSize);
}
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ function renderOldGame(g: OldGame): HTMLElement {
function renderLiveGame(g: LiveGame) {
return `
<div class="live-game used">
<div class="name">${sanitizeHTML(g.bname)} <span class="elo">${g.belo.toFixed(0)}</span></div>
<canvas></canvas>
<div class="name">${sanitizeHTML(g.wname)} <span class="elo">${g.welo.toFixed(0)}</span></div>
<canvas></canvas>
<div class="name">${sanitizeHTML(g.bname)} <span class="elo">${g.belo.toFixed(0)}</span></div>
</div>
`;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ async function updateOldGames() {
}

async function updateLiveGames() {
const req = await fetch("https://chess.stjo.dev/api/live-games/")
const req = await fetch("/api/live-games/")
const games = await req.json() as LiveGame[];

for (const gameId in livesGames) {
Expand Down

0 comments on commit 04e1c1d

Please sign in to comment.