Skip to content

Commit

Permalink
Merge pull request #16376 from kraktus/fix_report_au
Browse files Browse the repository at this point in the history
Puzzle report: only report if the move is in the solution
  • Loading branch information
ornicar authored Nov 8, 2024
2 parents af00fd8 + aa97213 commit cfdd017
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui/puzzle/src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class Report {
// more resilient than checking the turn directly, if eventually puzzles get generated from 'from position' games
const nodeTurn = node.fen.includes(' w ') ? 'white' : 'black';
if (
node.ply >= ctrl.initialNode.ply &&
nextMoveInSolution(node) &&
nodeTurn == ctrl.pov &&
ctrl.mainline.some((n: Tree.Node) => n.id == node.id)
) {
Expand Down Expand Up @@ -99,3 +99,10 @@ export default class Report {
});
};
}

// since we check the nodes of the opposite side, to know if we're
// in the solution we need to check the following move
const nextMoveInSolution = (before: Tree.Node) => {
const node = before.children[0];
return node && (node.puzzle === 'good' || node.puzzle === 'win');
};

0 comments on commit cfdd017

Please sign in to comment.