@@ -6,6 +6,7 @@ import EngineStats from "@/components/Analysis/EngineStats.vue";
6
6
import EngineButtons from " @/components/Analysis/EngineButtons.vue" ;
7
7
import Fen from " @/components/Analysis/Fen.vue" ;
8
8
import EngineLines from " @/components/Analysis/EngineLines.vue" ;
9
+ import Pgn from " @/components/Analysis/Pgn.vue" ;
9
10
10
11
import { Chessground } from " chessground" ;
11
12
import { Chess , SQUARES } from " chess.js" ;
@@ -34,6 +35,7 @@ export default defineComponent({
34
35
Fen: Fen ,
35
36
EngineButtons: EngineButtons ,
36
37
EngineLines: EngineLines ,
38
+ Pgn: Pgn ,
37
39
},
38
40
data() {
39
41
return {
@@ -81,6 +83,7 @@ export default defineComponent({
81
83
82
84
startFen: startpos ,
83
85
currentFen: startpos ,
86
+ currentPgn: " " ,
84
87
};
85
88
},
86
89
computed: {
@@ -95,6 +98,7 @@ export default defineComponent({
95
98
} else if (this .isEngineAlive ) {
96
99
status = " READY" ;
97
100
}
101
+
98
102
if (this .game .isCheckmate ()) {
99
103
status = " CHECKMATE" ;
100
104
} else if (this .game .isStalemate ()) {
@@ -163,21 +167,29 @@ export default defineComponent({
163
167
async playMoves(moves : string ) {
164
168
const movesArray = moves .trim ().split (" " );
165
169
170
+ await this .sendEngineCommand (" stop" );
171
+ this .engineLines .clear ();
172
+
166
173
for (let i = 0 ; i < movesArray .length ; i ++ ) {
174
+ if (this .game .isGameOver ()) {
175
+ this .currentFen = this .game .fen ();
176
+ this .currentPgn = this .game .pgn ();
177
+
178
+ return ;
179
+ }
180
+
167
181
const move = movesArray [i ];
168
182
169
183
if (this .game .move (move ) === null ) {
184
+ this .currentFen = this .game .fen ();
185
+ this .currentPgn = this .game .pgn ();
186
+
170
187
return ;
171
188
}
172
189
173
190
this .moveHistory += move + " " ;
174
191
}
175
192
176
- await this .sendEngineCommand (" stop" );
177
- await this .sendEngineCommand (" go" );
178
-
179
- this .engineLines .clear ();
180
-
181
193
this .cg ?.set ({
182
194
fen: this .game .fen (),
183
195
turnColor: this .toColor (),
@@ -188,7 +200,10 @@ export default defineComponent({
188
200
},
189
201
});
190
202
203
+ // await this.sendEngineCommand("go");
204
+
191
205
this .currentFen = this .game .fen ();
206
+ this .currentPgn = this .game .pgn ();
192
207
},
193
208
handleKeydown(event : KeyboardEvent ) {
194
209
event .preventDefault ();
@@ -290,6 +305,7 @@ export default defineComponent({
290
305
291
306
// force update of buttons
292
307
this .currentFen = this .game .fen ();
308
+ this .currentPgn = this .game .pgn ();
293
309
},
294
310
async sendOptions() {
295
311
this .activeEngine ?.settings .forEach ((option : Option ) => async () => {
@@ -322,6 +338,8 @@ export default defineComponent({
322
338
if (
323
339
this .engine_info .pv &&
324
340
this .engine_info .pv .length > 0 &&
341
+ this .engine_info .pv [0 ].orig != " " &&
342
+ this .engine_info .pv [0 ].dest != " " &&
325
343
this .isEngineAlive
326
344
) {
327
345
this .drawAnalysisMove (
@@ -448,6 +466,7 @@ export default defineComponent({
448
466
449
467
this .engineLines .clear ();
450
468
this .currentFen = this .game .fen ();
469
+ this .currentPgn = this .game .pgn ();
451
470
this .moveHistory += move .lan + " " ;
452
471
453
472
// update chessground board
@@ -593,6 +612,7 @@ export default defineComponent({
593
612
@send-moves =" playMoves"
594
613
:engineLines =" engineLines"
595
614
:fen =" currentFen"
615
+ :key =" currentFen"
596
616
:color =" toColor()"
597
617
/>
598
618
<EngineButtons
@@ -603,7 +623,8 @@ export default defineComponent({
603
623
/>
604
624
</div >
605
625
<div class =" nav-secondary-content" >
606
- <div class =" game-pgn" ></div >
626
+ <!-- <div class="game-pgn"></div> -->
627
+ <Pgn :gamePgn =" currentPgn" :key =" currentFen" />
607
628
<div class =" analysis-graph" ></div >
608
629
</div >
609
630
</div >
0 commit comments