show study game results in player bars

This commit is contained in:
Thibault Duplessis 2017-10-29 12:45:57 -05:00
parent 555070b5e7
commit f9d4fb8cd7
3 changed files with 30 additions and 6 deletions

View file

@ -763,7 +763,6 @@ div.chapter_embed {
height: 26px;
justify-content: space-between;
align-items: center;
padding-left: 10px;
font-size: 16px;
font-weight: bold;
position: absolute;
@ -785,9 +784,17 @@ body.dark .player_bar {
border-radius: 0 0 4px 4px;
bottom: -26px;
}
.player_bar .elo {
margin-left: 0.5em;
.player_bar .left {
flex: 1 1 100%;
display: flex;
justify-content: flex-start;
}
.player_bar .result {
flex: 0 0 auto;
margin-left: 10px;
font-weight: normal;
padding-right: 10px;
border-right: 1px solid rgba(127,127,127,0.5);
}
.player_bar .aclock {
font-family: 'Roboto Mono', 'Roboto';
@ -806,6 +813,13 @@ body.dark .player_bar {
color: #fff;
text-shadow: none;
}
.player_bar .info {
margin-left: 10px;
}
.player_bar .elo {
margin-left: 0.5em;
font-weight: normal;
}
.relay_players .cg-board-wrap coords.files {
bottom: 0px;

View file

@ -3,7 +3,7 @@ import { VNode } from 'snabbdom/vnode'
import { TagArray } from './interfaces';
import { renderClocks } from '../clocks';
import AnalyseCtrl from '../ctrl';
import { isFinished, findTag } from './studyChapters';
import { isFinished, findTag, resultOf } from './studyChapters';
interface PlayerNames {
white: string;
@ -26,12 +26,13 @@ export default function(ctrl: AnalyseCtrl): VNode[] | undefined {
function renderPlayer(tags: TagArray[], clocks: [VNode, VNode] | undefined, playerNames: PlayerNames, color: Color, ticking: boolean): VNode {
const title = findTag(tags, `${color}title`),
elo = findTag(tags, `${color}elo`);
elo = findTag(tags, `${color}elo`),
result = resultOf(tags, color === 'white');
return h(`div.player_bar.${color}`, {
class: { ticking }
}, [
h('div.left', [
h('span.color'),
result && h('span.result', result),
h('span.info', [
title && h('span.title', title + ' '),
h('span.name', playerNames[color]),

View file

@ -52,6 +52,15 @@ export function findTag(tags: TagArray[], name: string): string | undefined {
return t && t[1];
}
export function resultOf(tags: TagArray[], isWhite: boolean): string | undefined {
switch(findTag(tags, 'result')) {
case '1-0': return isWhite ? '1' : '0';
case '0-1': return isWhite ? '0' : '1';
case '1/2-1/2': return '1/2';
default: return;
}
}
export function view(ctrl: StudyCtrl): VNode {
const configButton = ctrl.members.canContribute() ? h('i.action.config', { attrs: dataIcon('%') }) : null;