Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use existing clockToSpeed function #16184

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/lobby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"common": "workspace:*",
"dasher": "workspace:*",
"debounce-promise": "^3.1.2",
"game": "workspace:*",
"snabbdom": "3.5.1"
},
"lichess": {
Expand Down
22 changes: 7 additions & 15 deletions ui/lobby/src/setupCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Prop, propWithEffect } from 'common';
import { debounce } from 'common/timing';
import * as xhr from 'common/xhr';
import { storedJsonProp, StoredJsonProp } from 'common/storage';
import { clockToSpeed } from 'game';
import LobbyController from './ctrl';
import {
ForceSetupOptions,
Expand All @@ -23,21 +24,12 @@ import {
variants,
} from './options';

const getPerf = (variant: VariantKey, timeMode: TimeMode, time: RealValue, increment: RealValue): Perf => {
if (!['standard', 'fromPosition'].includes(variant)) return variant as Perf;
if (timeMode !== 'realTime') return 'correspondence';

const totalGameTime = time * 60 + increment * 40;
return totalGameTime < 30
? 'ultraBullet'
: totalGameTime < 180
? 'bullet'
: totalGameTime < 480
? 'blitz'
: totalGameTime < 1500
? 'rapid'
: 'classical';
};
const getPerf = (variant: VariantKey, timeMode: TimeMode, time: RealValue, increment: RealValue): Perf =>
variant != 'standard' && variant != 'fromPosition'
? variant
: timeMode !== 'realTime'
? 'correspondence'
: clockToSpeed(time * 60, increment);

export default class SetupController {
root: LobbyController;
Expand Down
Loading