all speeds in POE

openingexplorer3
Thibault Duplessis 2021-10-19 19:03:52 +02:00
parent 86a6a0f0d6
commit ddc90fc190
6 changed files with 18 additions and 10 deletions

View File

@ -300,7 +300,7 @@ declare type VariantKey =
| 'racingKings'
| 'crazyhouse';
declare type Speed = 'bullet' | 'blitz' | 'classical' | 'correspondence';
declare type Speed = 'ultraBullet' | 'bullet' | 'blitz' | 'rapid' | 'classical' | 'correspondence';
declare type Perf =
| 'bullet'

View File

@ -5,9 +5,12 @@ import { storedProp, storedJsonProp, StoredJsonProp, StoredProp } from 'common/s
import { ExplorerDb, ExplorerSpeed, ExplorerMode } from './interfaces';
import { snabModal } from 'common/modal';
import AnalyseCtrl from '../ctrl';
import { perf } from 'game/perf';
import { iconTag } from '../util';
import { ucfirst } from './explorerUtil';
const allDbs: ExplorerDb[] = ['lichess', 'player'];
const allSpeeds: ExplorerSpeed[] = ['bullet', 'blitz', 'rapid', 'classical'];
const allSpeeds: ExplorerSpeed[] = ['ultraBullet', 'bullet', 'blitz', 'rapid', 'classical', 'correspondence'];
const allModes: ExplorerMode[] = ['casual', 'rated'];
const allRatings = [1600, 1800, 2000, 2200, 2500];
@ -138,15 +141,15 @@ const masterDb = (ctrl: ExplorerConfigCtrl) =>
]);
const radioButton =
<T>(ctrl: ExplorerConfigCtrl, storage: StoredJsonProp<T[]>) =>
<T>(ctrl: ExplorerConfigCtrl, storage: StoredJsonProp<T[]>, render?: (t: T) => VNode) =>
(v: T) =>
h(
'button',
{
attrs: { 'aria-pressed': `${storage().includes(v)}` },
attrs: { 'aria-pressed': `${storage().includes(v)}`, title: render ? ucfirst('' + v) : '' },
hook: bind('click', _ => ctrl.toggleMany(storage)(v), ctrl.root.redraw),
},
'' + v
render ? render(v) : '' + v
);
const lichessDb = (ctrl: ExplorerConfigCtrl) =>
@ -161,7 +164,7 @@ const lichessDb = (ctrl: ExplorerConfigCtrl) =>
const speedSection = (ctrl: ExplorerConfigCtrl) =>
h('section.speed', [
h('label', ctrl.root.trans.noarg('timeControl')),
h('div.choices', allSpeeds.map(radioButton(ctrl, ctrl.data.speed))),
h('div.choices', allSpeeds.map(radioButton(ctrl, ctrl.data.speed, s => iconTag(perf.icons[s])))),
]);
const modeSection = (ctrl: ExplorerConfigCtrl) =>

View File

@ -11,3 +11,5 @@ export function winnerOf(fen: Fen, move: TablebaseMoveStats): Color | undefined
if (move.variant_win || (move.dtz && move.dtz > 0)) return opposite(stm);
return undefined;
}
export const ucfirst = (str: string) => `${str[0].toUpperCase()}${str.slice(1)}`;

View File

@ -4,7 +4,7 @@ import { perf } from 'game/perf';
import { bind, dataIcon, MaybeVNode } from 'common/snabbdom';
import { defined } from 'common';
import { view as renderConfig } from './explorerConfig';
import { winnerOf } from './explorerUtil';
import { ucfirst, winnerOf } from './explorerUtil';
import AnalyseCtrl from '../ctrl';
import {
isOpening,
@ -155,7 +155,7 @@ function showGameTable(ctrl: AnalyseCtrl, title: string, games: OpeningGame[]):
game.speed &&
h('i', {
attrs: {
title: game.speed,
title: ucfirst(game.speed),
...dataIcon(perf.icons[game.speed]),
},
})

View File

@ -29,7 +29,10 @@ export async function opening(
params.set('play', opts.play.join(','));
if (opts.db === 'lichess') {
params.set('variant', opts.variant || 'standard');
for (const speed of conf.speed()) params.append('speeds[]', speed);
conf
.speed()
.filter(s => s != 'ultraBullet' && s != 'correspondence')
.forEach(s => params.append('speeds[]', s));
for (const rating of conf.rating()) params.append('ratings[]', rating.toString());
}
if (opts.db === 'player') {

View File

@ -5,7 +5,7 @@ export interface Hovering {
export type ExplorerDb = 'lichess' | 'masters' | 'player';
export type ExplorerSpeed = 'bullet' | 'blitz' | 'rapid' | 'classical';
export type ExplorerSpeed = Speed;
export type ExplorerMode = 'casual' | 'rated';
export interface PlayerOpts {