Skip to content

Commit

Permalink
remove redundant function
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Nov 13, 2024
1 parent 208d12d commit 498f5c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ui/chess/src/moveRootCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface MoveRootCtrl {
blindfold?: (v?: boolean) => boolean;
speakClock?: () => void;
goBerserk?: () => void;
shouldConfirmMove?: () => boolean;
confirmMoveToggle?: () => boolean;
}

export interface MoveUpdate {
Expand Down
7 changes: 2 additions & 5 deletions ui/round/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,13 @@ export default class RoundController implements MoveRootCtrl {
this.keyboardMove?.update({ fen, canMove: this.canMove() });
};

shouldConfirmMove = (): boolean =>
(this.data.pref.submitMove && this.confirmMoveToggle()) || this.confirmMoveToggle();

sendMove = (orig: Key, dest: Key, prom: Role | undefined, meta: MoveMetadata): void => {
const move: SocketMove = { u: orig + dest };
if (prom) move.u += prom === 'knight' ? 'n' : prom[0];
if (blur.get()) move.b = 1;
this.resign(false);

if (!meta.preConfirmed && this.shouldConfirmMove() && !meta.premove) {
if (!meta.preConfirmed && this.confirmMoveToggle() && !meta.premove) {
if (site.sound.speech()) {
const spoken = `${speakable(sanOf(readFen(this.stepAt(this.ply).fen), move.u))}. confirm?`;
site.sound.say(spoken, false, true);
Expand All @@ -359,7 +356,7 @@ export default class RoundController implements MoveRootCtrl {
const drop: SocketDrop = { role, pos: key };
if (blur.get()) drop.b = 1;
this.resign(false);
if (this.shouldConfirmMove() && !isPredrop) {
if (this.confirmMoveToggle() && !isPredrop) {
this.toSubmit = drop;
this.redraw();
} else {
Expand Down
2 changes: 1 addition & 1 deletion ui/voice/src/move/voice.move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export function initModule({
// trim choices to clarity window
options = options.filter(([, m]) => m.cost - lowestCost <= clarityThreshold);

if (!timer() && options.length === 1 && (options[0][1].cost < 0.3 || root.shouldConfirmMove?.())) {
if (!timer() && options.length === 1 && (options[0][1].cost < 0.3 || root.confirmMoveToggle?.())) {
console.info('chooseMoves', `chose '${options[0][0]}' cost=${options[0][1].cost}`);
submit(options[0][0], false);
return true;
Expand Down

0 comments on commit 498f5c9

Please sign in to comment.