Skip to content

Commit

Permalink
never render negative clocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Dec 28, 2024
1 parent 10b9967 commit f4d7042
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ui/analyse/src/view/clocks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, type VNode } from 'snabbdom';
import type AnalyseCtrl from '../ctrl';
import { notNull } from 'common';
import { defined, notNull } from 'common';
import * as licon from 'common/licon';
import { iconTag } from 'common/snabbdom';

Expand All @@ -17,7 +17,9 @@ export default function renderClocks(ctrl: AnalyseCtrl, path: Tree.Path): [VNode
whitePov = ctrl.bottomIsWhite(),
parentClock = ctrl.tree.getParentClock(node, path),
isWhiteTurn = node.ply % 2 === 0,
centis: Array<number | undefined> = isWhiteTurn ? [parentClock, node.clock] : [node.clock, parentClock];
centis: Array<number | undefined> = (
isWhiteTurn ? [parentClock, node.clock] : [node.clock, parentClock]
).map(c => (defined(c) && c < 0 ? undefined : c));

if (!centis.some(notNull)) return;

Expand Down

0 comments on commit f4d7042

Please sign in to comment.