Skip to content

Commit 933adfd

Browse files
committed
feat: show player titles on result rows and game page
Closes #14
1 parent 18c18fb commit 933adfd

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

components/ChessGameResultRow.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
<td>
44
<span class="d-flex align-center">
55
<span :class="['play-icon', unknownColor ? 'unknown' : 'white', cleanResult[0] == 1 ? 'winner' : '']" />
6+
<span v-if="whitePlayer.title"><chess-title :title="whitePlayer.title" size="x-small" />&nbsp;</span>
67
<span v-if="whitePlayer.id == null">{{ whitePlayer.name }}</span>
78
<PageLink v-else :href="`/profile/${whitePlayer.name}`">{{ whitePlayer.name }}</PageLink>
89
<span v-if="whitePlayer.elo" class="text-grey">&nbsp;({{ whitePlayer.elo }})</span>
910
</span>
1011
<span class="d-flex align-center">
1112
<span :class="['play-icon', unknownColor ? 'unknown' : 'black', cleanResult[1] == 1 ? 'winner' : '']" />
13+
<span v-if="blackPlayer.title"><chess-title :title="blackPlayer.title" size="x-small" />&nbsp;</span>
1214
<span v-if="blackPlayer.id == null">{{ blackPlayer.name }}</span>
1315
<PageLink v-else :href="`/profile/${blackPlayer.name}`">{{ blackPlayer.name }}</PageLink>
1416
<span v-if="blackPlayer.elo" class="text-grey">&nbsp;({{ blackPlayer.elo }})</span>
@@ -72,11 +74,11 @@ export default {
7274
name: 'ChessGameResultRow',
7375
props: {
7476
whitePlayer: {
75-
type: Object as PropType<{id: string | null, name: string, elo?: string|number}>,
77+
type: Object as PropType<{id: string | null, name: string, elo?: string|number, title?: string}>,
7678
required: true
7779
},
7880
blackPlayer: {
79-
type: Object as PropType<{id: string | null, name: string, elo?: string|number}>,
81+
type: Object as PropType<{id: string | null, name: string, elo?: string|number, title?: string}>,
8082
required: true
8183
},
8284
unknownColor: {

components/ChessTitle.vue

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export default defineComponent({
3838
3939
methods: {
4040
abbreviation() {
41+
// hard coded
42+
if (this.title === 'BOT') {
43+
return 'BOT'
44+
}
45+
4146
const title = this.title.replaceAll('Grandmaster', 'Grand Master').split(' ')
4247
4348
// first letter of every word in the title

pages/game/[id].vue

+11-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
<v-col cols="6">
5252
<v-card variant="tonal">
5353
<v-card-text>
54+
<span v-if="(whiteOnBottom ? blackTitle : whiteTitle) !== ''">
55+
<chess-title :title="whiteOnBottom ? blackTitle : whiteTitle" size="x-small" />
56+
</span>
5457
{{ whiteOnBottom ? black : white }}
5558
<span v-if="whiteOnBottom ? blackElo : whiteElo" class="text-grey-darken-1">
5659
({{ whiteOnBottom ? blackElo : whiteElo }})
@@ -71,6 +74,9 @@
7174
<v-col cols="6">
7275
<v-card variant="tonal">
7376
<v-card-text>
77+
<span v-if="(whiteOnBottom ? whiteTitle : blackTitle) !== ''">
78+
<chess-title :title="whiteOnBottom ? whiteTitle : blackTitle" size="x-small" />
79+
</span>
7480
{{ whiteOnBottom ? white : black }}
7581
<span v-if="whiteOnBottom ? whiteElo : blackElo" class="text-grey-darken-1">
7682
({{ whiteOnBottom ? whiteElo : blackElo }})
@@ -188,8 +194,10 @@ export default defineComponent({
188194
189195
white: 'meow',
190196
whiteElo: '0',
197+
whiteTitle: '',
191198
black: 'meow',
192-
blackElo: '0'
199+
blackElo: '0',
200+
blackTitle: ''
193201
}
194202
},
195203
@@ -308,8 +316,10 @@ export default defineComponent({
308316
309317
if (pgn.White) { this.white = pgn.White }
310318
if (pgn.WhiteElo) { this.whiteElo = pgn.WhiteElo }
319+
if (pgn.WhiteTitle) { this.whiteTitle = pgn.WhiteTitle }
311320
if (pgn.Black) { this.black = pgn.Black }
312321
if (pgn.BlackElo) { this.blackElo = pgn.BlackElo }
322+
if (pgn.BlackTitle) { this.blackTitle = pgn.BlackTitle }
313323
},
314324
315325
async savePGN(data: Record<string, any>, pgn: Record<string, string>, tournamentInfo: TournamentJson | null) {

utils/games.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Chess } from 'chess.js'
2-
import { TableGames } from '~/types/supabase'
2+
import type { TableGames } from '~/types/supabase'
33

44
export type CleanedGame = {
55
id: string,
6-
whitePlayer: {id: string | null, name: string, elo?: string|number},
7-
blackPlayer: {id: string | null, name: string, elo?: string|number},
6+
whitePlayer: {id: string | null, name: string, elo?: string|number, title?: string},
7+
blackPlayer: {id: string | null, name: string, elo?: string|number, title?: string},
88
cleanResult: (number|string)[],
99
friendlyResult: string,
1010
date?: string,
@@ -62,8 +62,8 @@ export function cleanGame(game: TableGames, userId?: string, users?: { id: strin
6262

6363
return {
6464
id: game.id,
65-
whitePlayer: { ...white, elo: pgn.WhiteElo },
66-
blackPlayer: { ...black, elo: pgn.BlackElo },
65+
whitePlayer: { ...white, elo: pgn.WhiteElo, title: pgn.WhiteTitle },
66+
blackPlayer: { ...black, elo: pgn.BlackElo, title: pgn.BlackTitle },
6767
cleanResult: result,
6868
friendlyResult,
6969
date

0 commit comments

Comments
 (0)