Skip to content

Commit

Permalink
Merge pull request #16184 from allanjoseph98/clockToSpeed
Browse files Browse the repository at this point in the history
use existing `clockToSpeed` function
  • Loading branch information
ornicar authored Oct 7, 2024
2 parents fcd1950 + d193002 commit 0f7da32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
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

0 comments on commit 0f7da32

Please sign in to comment.