Skip to content

Commit 6e8bbf6

Browse files
fix: move numbers in critical decisions
1 parent 3afa6c6 commit 6e8bbf6

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

src/components/Openings/DrillPerformanceModal.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -868,14 +868,18 @@ const DesktopLayout: React.FC<{
868868
.filter((move) => {
869869
// Determine if this is a player move using the same logic as elsewhere
870870
const isWhiteMove = isMoveByWhite(move.fen)
871-
const isPlayerMove = drill.selection.playerColor === 'white'
872-
? isWhiteMove
873-
: !isWhiteMove
871+
const isPlayerMove =
872+
drill.selection.playerColor === 'white'
873+
? isWhiteMove
874+
: !isWhiteMove
874875
return isPlayerMove
875876
})
876877
.map((move) => {
877878
// Get classification from our helper function
878-
const classification = getChartClassification(move, gameNodesMap)
879+
const classification = getChartClassification(
880+
move,
881+
gameNodesMap,
882+
)
879883
// Get the correct move number from the FEN
880884
const actualMoveNumber = getMoveNumberFromFen(move.fen)
881885
return {
@@ -886,7 +890,9 @@ const DesktopLayout: React.FC<{
886890
})
887891
.filter((move) => {
888892
// Filter for critical moves (not just 'good')
889-
return ['excellent', 'inaccuracy', 'blunder'].includes(move.classification)
893+
return ['excellent', 'inaccuracy', 'blunder'].includes(
894+
move.classification,
895+
)
890896
})
891897
.sort((a, b) => {
892898
// Sort by move number (chronological order)
@@ -1252,10 +1258,15 @@ export const DrillPerformanceModal: React.FC<Props> = ({
12521258

12531259
// Find the opening end node by working backwards from the final node
12541260
// The opening end should be the first move analysis that is NOT a player move
1255-
const firstPlayerMoveAnalysis = moveAnalyses.find(move => move.isPlayerMove)
1261+
const firstPlayerMoveAnalysis = moveAnalyses.find(
1262+
(move) => move.isPlayerMove,
1263+
)
12561264
if (firstPlayerMoveAnalysis && firstPlayerMoveAnalysis.fenBeforeMove) {
12571265
// Find the node that represents the position before the first player move
1258-
const findNodeByFen = (node: GameNode, targetFen: string): GameNode | null => {
1266+
const findNodeByFen = (
1267+
node: GameNode,
1268+
targetFen: string,
1269+
): GameNode | null => {
12591270
if (node.fen === targetFen) {
12601271
return node
12611272
}
@@ -1272,7 +1283,10 @@ export const DrillPerformanceModal: React.FC<Props> = ({
12721283
return null
12731284
}
12741285

1275-
const foundOpeningEndNode = findNodeByFen(originalRoot, firstPlayerMoveAnalysis.fenBeforeMove)
1286+
const foundOpeningEndNode = findNodeByFen(
1287+
originalRoot,
1288+
firstPlayerMoveAnalysis.fenBeforeMove,
1289+
)
12761290
if (foundOpeningEndNode) {
12771291
return {
12781292
gameTree: originalGameTree,

0 commit comments

Comments
 (0)