hide ratings in swiss tournaments
parent
6833e78bc4
commit
31b7850442
|
@ -47,7 +47,8 @@ object show {
|
|||
resourceId = lila.chat.Chat.ResourceId(s"swiss/${c.chat.id}"),
|
||||
localMod = isLocalMod
|
||||
)
|
||||
}
|
||||
},
|
||||
"showRatings" -> ctx.pref.showRatings
|
||||
)
|
||||
.add("schedule" -> hasScheduleInput)
|
||||
)})""")
|
||||
|
|
|
@ -14,6 +14,7 @@ export interface SwissOpts {
|
|||
chat: any;
|
||||
i18n: I18nDict;
|
||||
classes: string | null;
|
||||
showRatings: boolean;
|
||||
}
|
||||
|
||||
export interface SwissData {
|
||||
|
|
|
@ -1,46 +1,48 @@
|
|||
import { Board, SwissOpts } from '../interfaces';
|
||||
import { h, VNode } from 'snabbdom';
|
||||
import { opposite } from 'chessground/util';
|
||||
import { player as renderPlayer } from './util';
|
||||
import { Board } from '../interfaces';
|
||||
|
||||
export function many(boards: Board[]): VNode {
|
||||
return h('div.swiss__boards.now-playing', boards.map(renderBoard));
|
||||
export function many(boards: Board[], opts: SwissOpts): VNode {
|
||||
return h('div.swiss__boards.now-playing', boards.map(renderBoard(opts)));
|
||||
}
|
||||
|
||||
export function top(boards: Board[]): VNode {
|
||||
return h('div.swiss__board__top.swiss__table', boards.slice(0, 1).map(renderBoard));
|
||||
export function top(boards: Board[], opts: SwissOpts): VNode {
|
||||
return h('div.swiss__board__top.swiss__table', boards.slice(0, 1).map(renderBoard(opts)));
|
||||
}
|
||||
|
||||
const renderBoard = (board: Board): VNode =>
|
||||
h(
|
||||
`div.swiss__board.mini-game.mini-game-${board.id}.mini-game--init.is2d`,
|
||||
{
|
||||
key: board.id,
|
||||
attrs: {
|
||||
'data-state': `${board.fen},${board.orientation},${board.lastMove}`,
|
||||
'data-live': board.id,
|
||||
},
|
||||
hook: {
|
||||
insert(vnode) {
|
||||
lichess.powertip.manualUserIn(vnode.elm as HTMLElement);
|
||||
},
|
||||
},
|
||||
},
|
||||
[
|
||||
boardPlayer(board, opposite(board.orientation)),
|
||||
h('a.cg-wrap', {
|
||||
const renderBoard =
|
||||
(opts: SwissOpts) =>
|
||||
(board: Board): VNode =>
|
||||
h(
|
||||
`div.swiss__board.mini-game.mini-game-${board.id}.mini-game--init.is2d`,
|
||||
{
|
||||
key: board.id,
|
||||
attrs: {
|
||||
href: `/${board.id}/${board.orientation}`,
|
||||
'data-state': `${board.fen},${board.orientation},${board.lastMove}`,
|
||||
'data-live': board.id,
|
||||
},
|
||||
}),
|
||||
boardPlayer(board, board.orientation),
|
||||
]
|
||||
);
|
||||
hook: {
|
||||
insert(vnode) {
|
||||
lichess.powertip.manualUserIn(vnode.elm as HTMLElement);
|
||||
},
|
||||
},
|
||||
},
|
||||
[
|
||||
boardPlayer(board, opposite(board.orientation), opts),
|
||||
h('a.cg-wrap', {
|
||||
attrs: {
|
||||
href: `/${board.id}/${board.orientation}`,
|
||||
},
|
||||
}),
|
||||
boardPlayer(board, board.orientation, opts),
|
||||
]
|
||||
);
|
||||
|
||||
function boardPlayer(board: Board, color: Color) {
|
||||
function boardPlayer(board: Board, color: Color, opts: SwissOpts) {
|
||||
const player = board[color];
|
||||
return h('span.mini-game__player', [
|
||||
h('span.mini-game__user', [h('strong', '#' + player.rank), renderPlayer(player, true, true)]),
|
||||
h('span.mini-game__user', [h('strong', '#' + player.rank), renderPlayer(player, true, opts.showRatings)]),
|
||||
board.clock
|
||||
? h(`span.mini-game__clock.mini-game__clock--${color}`, {
|
||||
attrs: {
|
||||
|
|
|
@ -35,8 +35,8 @@ export default function (ctrl: SwissCtrl) {
|
|||
$(el).replaceWith($('.swiss__underchat.none').removeClass('none'));
|
||||
}),
|
||||
}),
|
||||
playerInfo(ctrl) || stats(ctrl) || boards.top(d.boards),
|
||||
h('div.swiss__main', [h('div.box.swiss__main-' + d.status, content), boards.many(d.boards)]),
|
||||
playerInfo(ctrl) || stats(ctrl) || boards.top(d.boards, ctrl.opts),
|
||||
h('div.swiss__main', [h('div.box.swiss__main-' + d.status, content), boards.many(d.boards, ctrl.opts)]),
|
||||
ctrl.opts.chat
|
||||
? h('div.chat__members.none', {
|
||||
hook: onInsert(lichess.watchers),
|
||||
|
@ -233,7 +233,7 @@ function stats(ctrl: SwissCtrl): VNode | undefined {
|
|||
? h('div.swiss__stats', [
|
||||
h('h2', noarg('tournamentComplete')),
|
||||
h('table', [
|
||||
numberRow(noarg('averageElo'), s.averageRating, 'raw'),
|
||||
ctrl.opts.showRatings ? numberRow(noarg('averageElo'), s.averageRating, 'raw') : null,
|
||||
numberRow(noarg('gamesPlayed'), s.games),
|
||||
numberRow(noarg('whiteWins'), [s.whiteWins, slots], 'percent'),
|
||||
numberRow(noarg('blackWins'), [s.blackWins, slots], 'percent'),
|
||||
|
|
|
@ -39,11 +39,11 @@ export default function (ctrl: SwissCtrl): VNode | undefined {
|
|||
numberRow('Tie break', data.tieBreak, 'raw'),
|
||||
...(games
|
||||
? [
|
||||
data.performance
|
||||
data.performance && ctrl.opts.showRatings
|
||||
? numberRow(noarg('performance'), data.performance + (games < 3 ? '?' : ''), 'raw')
|
||||
: null,
|
||||
numberRow(noarg('winRate'), [wins, games], 'percent'),
|
||||
numberRow(noarg('averageOpponent'), avgOp, 'raw'),
|
||||
ctrl.opts.showRatings ? numberRow(noarg('averageOpponent'), avgOp, 'raw') : null,
|
||||
]
|
||||
: []),
|
||||
]),
|
||||
|
@ -84,7 +84,7 @@ export default function (ctrl: SwissCtrl): VNode | undefined {
|
|||
[
|
||||
h('th', '' + round),
|
||||
h('td', userName(p.user)),
|
||||
h('td', '' + p.rating),
|
||||
ctrl.opts.showRatings ? h('td', '' + p.rating) : null,
|
||||
h('td.is.color-icon.' + (p.c ? 'white' : 'black')),
|
||||
h('td', res),
|
||||
]
|
||||
|
|
|
@ -3,16 +3,16 @@ import SwissCtrl from '../ctrl';
|
|||
import { PodiumPlayer } from '../interfaces';
|
||||
import { userName } from './util';
|
||||
|
||||
function podiumStats(p: PodiumPlayer, trans: Trans): VNode {
|
||||
const noarg = trans.noarg;
|
||||
return h('table.stats', [
|
||||
const podiumStats = (p: PodiumPlayer, ctrl: SwissCtrl): VNode =>
|
||||
h('table.stats', [
|
||||
h('tr', [h('th', 'Points'), h('td', '' + p.points)]),
|
||||
h('tr', [h('th', 'Tie Break'), h('td', '' + p.tieBreak)]),
|
||||
p.performance ? h('tr', [h('th', noarg('performance')), h('td', '' + p.performance)]) : null,
|
||||
p.performance && ctrl.opts.showRatings
|
||||
? h('tr', [h('th', ctrl.trans.noarg('performance')), h('td', '' + p.performance)])
|
||||
: null,
|
||||
]);
|
||||
}
|
||||
|
||||
function podiumPosition(p: PodiumPlayer, pos: string, trans: Trans): VNode | undefined {
|
||||
function podiumPosition(p: PodiumPlayer, pos: string, ctrl: SwissCtrl): VNode | undefined {
|
||||
return p
|
||||
? h(
|
||||
'div.' + pos,
|
||||
|
@ -30,7 +30,7 @@ function podiumPosition(p: PodiumPlayer, pos: string, trans: Trans): VNode | und
|
|||
},
|
||||
userName(p.user)
|
||||
),
|
||||
podiumStats(p, trans),
|
||||
podiumStats(p, ctrl),
|
||||
]
|
||||
)
|
||||
: undefined;
|
||||
|
@ -39,8 +39,8 @@ function podiumPosition(p: PodiumPlayer, pos: string, trans: Trans): VNode | und
|
|||
export default function podium(ctrl: SwissCtrl) {
|
||||
const p = ctrl.data.podium || [];
|
||||
return h('div.podium', [
|
||||
podiumPosition(p[1], 'second', ctrl.trans),
|
||||
podiumPosition(p[0], 'first', ctrl.trans),
|
||||
podiumPosition(p[2], 'third', ctrl.trans),
|
||||
podiumPosition(p[1], 'second', ctrl),
|
||||
podiumPosition(p[0], 'first', ctrl),
|
||||
podiumPosition(p[2], 'third', ctrl),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ function playerTr(ctrl: SwissCtrl, player: Player) {
|
|||
})
|
||||
: [player.rank]
|
||||
),
|
||||
h('td.player', renderPlayer(player, false, true)),
|
||||
h('td.player', renderPlayer(player, false, ctrl.opts.showRatings)),
|
||||
h(
|
||||
'td.pairings',
|
||||
h(
|
||||
|
|
|
@ -66,11 +66,11 @@ function podiumUsername(p: PodiumPlayer) {
|
|||
);
|
||||
}
|
||||
|
||||
function podiumStats(p: PodiumPlayer, berserkable: boolean, trans: Trans): VNode {
|
||||
const noarg = trans.noarg,
|
||||
function podiumStats(p: PodiumPlayer, berserkable: boolean, ctrl: TournamentController): VNode {
|
||||
const noarg = ctrl.trans.noarg,
|
||||
nb = p.nb;
|
||||
return h('table.stats', [
|
||||
p.performance ? h('tr', [h('th', noarg('performance')), h('td', p.performance)]) : null,
|
||||
p.performance && ctrl.opts.showRatings ? h('tr', [h('th', noarg('performance')), h('td', p.performance)]) : null,
|
||||
h('tr', [h('th', noarg('gamesPlayed')), h('td', nb.game)]),
|
||||
...(nb.game
|
||||
? [
|
||||
|
@ -81,8 +81,13 @@ function podiumStats(p: PodiumPlayer, berserkable: boolean, trans: Trans): VNode
|
|||
]);
|
||||
}
|
||||
|
||||
function podiumPosition(p: PodiumPlayer, pos: string, berserkable: boolean, trans: Trans): VNode | undefined {
|
||||
if (p) return h('div.' + pos, [h('div.trophy'), podiumUsername(p), podiumStats(p, berserkable, trans)]);
|
||||
function podiumPosition(
|
||||
p: PodiumPlayer,
|
||||
pos: string,
|
||||
berserkable: boolean,
|
||||
ctrl: TournamentController
|
||||
): VNode | undefined {
|
||||
if (p) return h('div.' + pos, [h('div.trophy'), podiumUsername(p), podiumStats(p, berserkable, ctrl)]);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -91,9 +96,9 @@ let lastBody: MaybeVNodes | undefined;
|
|||
export function podium(ctrl: TournamentController) {
|
||||
const p = ctrl.data.podium || [];
|
||||
return h('div.podium', [
|
||||
podiumPosition(p[1], 'second', ctrl.data.berserkable, ctrl.trans),
|
||||
podiumPosition(p[0], 'first', ctrl.data.berserkable, ctrl.trans),
|
||||
podiumPosition(p[2], 'third', ctrl.data.berserkable, ctrl.trans),
|
||||
podiumPosition(p[1], 'second', ctrl.data.berserkable, ctrl),
|
||||
podiumPosition(p[0], 'first', ctrl.data.berserkable, ctrl),
|
||||
podiumPosition(p[2], 'third', ctrl.data.berserkable, ctrl),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue