From 93cf3d39d215faa6202707ceb596f201921d0973 Mon Sep 17 00:00:00 2001 From: Craig Laparo Date: Thu, 29 Aug 2024 11:17:23 -0500 Subject: [PATCH] Combine evaluation and pv comments --- src/components/drawers/BotSuggestions.vue | 44 +++++++++-------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/src/components/drawers/BotSuggestions.vue b/src/components/drawers/BotSuggestions.vue index 390159c4..773fed64 100644 --- a/src/components/drawers/BotSuggestions.vue +++ b/src/components/drawers/BotSuggestions.vue @@ -446,15 +446,6 @@ export default { ); }, - plyHasPVComment(ply, pv = null) { - return ( - ply.id in this.game.comments.notes && - this.game.comments.notes[ply.id].some((comment) => - pv === null ? comment.pv : comment.message === pv - ) - ); - }, - getEvalComments(ply, settingsHash) { let comments = []; let positionBefore = this.positions[ply.tpsBefore]; @@ -492,7 +483,22 @@ export default { ? evaluationAfter : positionAfter[settingsHash][0].evaluation) ) / 1e4; - comments.push(`${evaluationAfter >= 0 ? "+" : ""}${evaluationAfter}`); + let evaluationComment = `${ + evaluationAfter >= 0 ? "+" : "" + }${evaluationAfter}`; + + if (positionBefore && settingsHash in positionBefore) { + let position = positionBefore[settingsHash][0]; + if (position && position.ply) { + let pv = [position.ply, ...position.followingPlies] + .slice(0, 3) + .map((ply) => ply.ptn); + evaluationComment += `, pv ${pv.join(" ")}`; + } + } + + comments.push(evaluationComment); + if ( evaluationBefore !== null || (positionBefore && settingsHash in positionBefore) @@ -524,20 +530,6 @@ export default { return comments; }, - getPVComment(ply, settingsHash) { - let positionBefore = this.positions[ply.tpsBefore]; - if (positionBefore && settingsHash in positionBefore) { - let position = positionBefore[settingsHash][0]; - if (position && position.ply) { - let pv = [position.ply, ...position.followingPlies] - .slice(0, 3) - .map((ply) => ply.ptn); - return `pv ${pv.join(" ")}`; - } - } - return null; - }, - goToAnalysisPly() { if (this.analyzingPly) { this.$store.dispatch("game/GO_TO_PLY", { @@ -600,10 +592,6 @@ export default { if (evaluations.length) { notes.push(...evaluations); } - let pv = this.getPVComment(ply, settingsHash); - if (pv !== null && !this.plyHasPVComment(ply, pv)) { - notes.push(pv); - } messages[ply.id] = notes; }); this.$store.dispatch("game/ADD_NOTES", messages);