Skip to content

Commit

Permalink
Puzzle: only show feedback on your moves
Browse files Browse the repository at this point in the history
Consistent feedback requested it, and prior behavior was a bit strange, especially after capture where the checkmark would now be on the piece of the opposite color.

This has the side-effect of effectively disabling the checkmark for users with animation set to "none", and I'd argue it's better and consistent.

See attached videos for the before and after.
  • Loading branch information
kraktus committed Aug 3, 2024
1 parent 3c4c0d1 commit ee2fee9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ui/puzzle/src/autoShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,19 @@ export default function (opts: Opts): DrawShape[] {
});
} else shapes = shapes.concat(makeAutoShapesFromUci(opposite(color), n.threat.pvs[0].moves[0], 'red'));
}
const feedback = feedbackAnnotation(n, opts.nodeList[opts.nodeList.length - 2]);
const feedback = feedbackAnnotation(n);
return shapes.concat(annotationShapes(n)).concat(feedback ? annotationShapes(feedback) : []);
}

function feedbackAnnotation(n: Tree.Node, prev?: Tree.Node): Tree.Node | undefined {
function feedbackAnnotation(n: Tree.Node): Tree.Node | undefined {
let glyph: Tree.Glyph | undefined;
const node = n.puzzle ? n : prev?.puzzle ? prev : undefined;
switch (node?.puzzle) {
switch (n.puzzle) {
case 'good':
case 'win':
glyph = { id: 7, name: 'good', symbol: '✓' };
break;
case 'fail':
glyph = { id: 4, name: 'fail', symbol: '✗' };
}
return node && glyph && { ...node, glyphs: [glyph] };
return glyph && { ...n, glyphs: [glyph] };
}

0 comments on commit ee2fee9

Please sign in to comment.