Fix parseInt() usage, rename Doubleorda --> Ordamirror, implement Clorange variant
[vchess.git] / client / src / components / BaseGame.vue
1 <template lang="pug">
2 div#baseGame
3 input#modalEog.modal(type="checkbox")
4 div#eogDiv(
5 role="dialog"
6 data-checkbox="modalEog"
7 )
8 .card.text-center
9 label.modal-close(for="modalEog")
10 h3.section {{ endgameMessage }}
11 #gameContainer
12 #boardContainer
13 Board(
14 ref="board"
15 :vr="vr"
16 :last-move="lastMove"
17 :analyze="mode=='analyze'"
18 :score="game.score"
19 :user-color="game.mycolor"
20 :orientation="orientation"
21 :vname="game.vname"
22 :incheck="incheck"
23 @play-move="play"
24 @click-square="clickSquare"
25 )
26 #turnIndicator(v-if="showTurn") {{ turn }}
27 #controls.button-group
28 button(@click="gotoBegin()")
29 img.inline(src="/images/icons/fast-forward_rev.svg")
30 button(@click="undo()")
31 img.inline(src="/images/icons/play_rev.svg")
32 button(v-if="canFlip" @click="flip()")
33 img.inline(src="/images/icons/flip.svg")
34 button(
35 @click="runAutoplay()"
36 :class="{'in-autoplay': autoplay}"
37 )
38 img.inline(src="/images/icons/autoplay.svg")
39 button(@click="play()")
40 img.inline(src="/images/icons/play.svg")
41 button(@click="gotoEnd()")
42 img.inline(src="/images/icons/fast-forward.svg")
43 p#fenAnalyze(v-show="showFen") {{ (!!vr ? vr.getFen() : "") }}
44 #movesList
45 MoveList(
46 :show="showMoves"
47 :canAnalyze="canAnalyze"
48 :canDownload="allowDownloadPGN"
49 :score="game.score"
50 :message="game.scoreMsg"
51 :firstNum="firstMoveNumber"
52 :moves="moves"
53 :cursor="cursor"
54 :vname="game.vname"
55 @download="download"
56 @showrules="showRules"
57 @analyze="toggleAnalyze"
58 @goto-move="gotoMove"
59 @redraw-board="redrawBoard"
60 )
61 .clearer
62 </template>
63
64 <script>
65 import Board from "@/components/Board.vue";
66 import MoveList from "@/components/MoveList.vue";
67 import params from "@/parameters";
68 import { store } from "@/store";
69 import { getSquareId } from "@/utils/squareId";
70 import { getDate } from "@/utils/datetime";
71 import { processModalClick } from "@/utils/modalClick";
72 import { getScoreMessage } from "@/utils/scoring";
73 import { getFullNotation } from "@/utils/notation";
74 import { undoMove } from "@/utils/playUndo";
75 export default {
76 name: "my-base-game",
77 components: {
78 Board,
79 MoveList
80 },
81 props: ["game"],
82 data: function() {
83 return {
84 st: store.state,
85 // NOTE: all following variables must be reset at the beginning of a game
86 vr: null, //VariantRules object, game state
87 endgameMessage: "",
88 orientation: "w",
89 mode: "",
90 gameMode: "",
91 score: "*", //'*' means 'unfinished'
92 moves: [],
93 cursor: -1, //index of the move just played
94 lastMove: null,
95 firstMoveNumber: 0, //for printing
96 incheck: [], //for Board
97 inMultimove: false,
98 autoplay: false,
99 inPlay: false,
100 stackToPlay: []
101 };
102 },
103 computed: {
104 turn: function() {
105 if (!this.vr) return "";
106 if (this.vr.showMoves != "all") {
107 return this.st.tr[
108 (this.vr.turn == 'w' ? "White" : "Black") + " to move"];
109 }
110 // Cannot flip (racing king or circular chess), or Monochrome
111 return (
112 this.vr.movesCount == 0 && this.game.mycolor == "w"
113 ? this.st.tr["It's your turn!"]
114 : ""
115 );
116 },
117 showFen: function() {
118 return (
119 this.mode == "analyze" &&
120 this.$router.currentRoute.path.indexOf("/analyse") === -1
121 );
122 },
123 // TODO: is it OK to pass "computed" as properties?
124 // Also, some are seemingly not recomputed when vr is initialized.
125 showMoves: function() {
126 return (
127 !!this.game.score && this.game.score != "*"
128 ? "all"
129 : (!!this.vr ? this.vr.showMoves : "none")
130 );
131 },
132 showTurn: function() {
133 return (
134 !!this.game.score && this.game.score == '*' &&
135 !!this.vr &&
136 (
137 this.vr.showMoves != "all" ||
138 !this.vr.canFlip ||
139 this.vr.showFirstTurn
140 )
141 );
142 },
143 canAnalyze: function() {
144 return (
145 (!this.game.mode || this.game.mode != "analyze") &&
146 !!this.vr && this.vr.canAnalyze
147 );
148 },
149 canFlip: function() {
150 return !!this.vr && this.vr.canFlip;
151 },
152 allowDownloadPGN: function() {
153 return (
154 (!!this.game.score && this.game.score != "*") ||
155 (!!this.vr && !this.vr.someHiddenMoves)
156 );
157 }
158 },
159 created: function() {
160 if (!!this.game.fenStart) this.re_setVariables();
161 },
162 mounted: function() {
163 if (!("ontouchstart" in window)) {
164 // Desktop browser:
165 const baseGameDiv = document.getElementById("baseGame");
166 baseGameDiv.tabIndex = 0;
167 baseGameDiv.addEventListener("click", this.focusBg);
168 baseGameDiv.addEventListener("keydown", this.handleKeys);
169 baseGameDiv.addEventListener("wheel", this.handleScroll);
170 }
171 document.getElementById("eogDiv")
172 .addEventListener("click", processModalClick);
173 },
174 beforeDestroy: function() {
175 // TODO: probably not required
176 this.autoplay = false;
177 },
178 methods: {
179 focusBg: function() {
180 document.getElementById("baseGame").focus();
181 },
182 handleKeys: function(e) {
183 if ([32, 37, 38, 39, 40].includes(e.keyCode)) e.preventDefault();
184 switch (e.keyCode) {
185 case 37:
186 this.undo();
187 break;
188 case 39:
189 this.play();
190 break;
191 case 38:
192 this.gotoBegin();
193 break;
194 case 40:
195 this.gotoEnd();
196 break;
197 case 32:
198 this.flip();
199 break;
200 }
201 },
202 handleScroll: function(e) {
203 e.preventDefault();
204 if (e.deltaY < 0) this.undo();
205 else if (e.deltaY > 0) this.play();
206 },
207 redrawBoard: function() {
208 this.$refs["board"].re_setDrawings();
209 },
210 showRules: function() {
211 // The button is here only on Game page:
212 document.getElementById("modalRules").checked = true;
213 },
214 re_setVariables: function(game) {
215 if (!game) game = this.game; //in case of...
216 this.endgameMessage = "";
217 // "w": default orientation for observed games
218 this.orientation = game.mycolor || "w";
219 this.mode = game.mode || game.type; //TODO: merge...
220 this.moves = JSON.parse(JSON.stringify(game.moves || []));
221 // Post-processing: decorate each move with notation and FEN
222 this.vr = new V(game.fenStart);
223 this.inMultimove = false; //in case of
224 if (!!this.$refs["board"])
225 // Also in case of:
226 this.$refs["board"].resetCurrentAttempt();
227 let analyseBtn = document.getElementById("analyzeBtn");
228 if (!!analyseBtn) analyseBtn.classList.remove("active");
229 const parsedFen = V.ParseFen(game.fenStart);
230 const firstMoveColor = parsedFen.turn;
231 this.firstMoveNumber = Math.floor(parsedFen.movesCount / 2) + 1;
232 let L = this.moves.length;
233 if (L == 0) {
234 // Could be started on a random position in analysis mode:
235 this.incheck = this.vr.getCheckSquares();
236 this.score = this.vr.getCurrentScore();
237 if (this.score != '*') {
238 // Show score on screen
239 const message = getScoreMessage(this.score);
240 this.showEndgameMsg(this.score + " . " + this.st.tr[message]);
241 }
242 }
243 else {
244 this.moves.forEach((move,idx) => {
245 // Strategy working also for multi-moves:
246 if (!Array.isArray(move)) move = [move];
247 const Lm = move.length;
248 move.forEach((m,idxM) => {
249 m.notation = this.vr.getNotation(m);
250 m.unambiguous = V.GetUnambiguousNotation(m);
251 this.vr.play(m);
252 const checkSquares = this.vr.getCheckSquares();
253 if (checkSquares.length > 0) m.notation += "+";
254 if (idxM == Lm - 1) m.fen = this.vr.getFen();
255 if (idx == L - 1 && idxM == Lm - 1) {
256 this.incheck = checkSquares;
257 this.score = this.vr.getCurrentScore();
258 if (["1-0", "0-1"].includes(this.score)) m.notation += "#";
259 }
260 });
261 });
262 }
263 if (firstMoveColor == "b") {
264 // 'start' & 'end' is required for Board component
265 this.moves.unshift({
266 notation: "...",
267 unambiguous: "...",
268 start: { x: -1, y: -1 },
269 end: { x: -1, y: -1 },
270 fen: game.fenStart
271 });
272 L++;
273 }
274 this.positionCursorTo(L - 1);
275 },
276 positionCursorTo: function(index) {
277 this.cursor = index;
278 // Note: last move in moves array might be a multi-move
279 if (index >= 0) this.lastMove = this.moves[index];
280 else this.lastMove = null;
281 },
282 toggleAnalyze: function() {
283 // Freeze while choices are shown (and autoplay has priority)
284 if (
285 this.inPlay ||
286 this.$refs["board"].choices.length > 0 ||
287 this.autoplay
288 ) {
289 return;
290 }
291 if (this.mode != "analyze") {
292 // Enter analyze mode:
293 this.gameMode = this.mode; //was not 'analyze'
294 this.mode = "analyze";
295 if (this.inMultimove) this.cancelCurrentMultimove();
296 this.gameCursor = this.cursor;
297 this.gameMoves = JSON.parse(JSON.stringify(this.moves));
298 document.getElementById("analyzeBtn").classList.add("active");
299 }
300 else {
301 // Exit analyze mode:
302 this.mode = this.gameMode;
303 this.cursor = this.gameCursor;
304 this.moves = this.gameMoves;
305 let fen = this.game.fenStart;
306 if (this.cursor >= 0) {
307 let mv = this.moves[this.cursor];
308 if (!Array.isArray(mv)) mv = [mv];
309 fen = mv[mv.length-1].fen;
310 }
311 this.vr = new V(fen);
312 this.inMultimove = false; //in case of
313 this.$refs["board"].resetCurrentAttempt(); //also in case of
314 this.incheck = this.vr.getCheckSquares();
315 if (this.cursor >= 0) this.lastMove = this.moves[this.cursor];
316 else this.lastMove = null;
317 document.getElementById("analyzeBtn").classList.remove("active");
318 }
319 },
320 download: function() {
321 const content = this.getPgn();
322 // Prepare and trigger download link
323 let downloadAnchor = document.getElementById("download");
324 downloadAnchor.setAttribute("download", "game.pgn");
325 downloadAnchor.href =
326 "data:text/plain;charset=utf-8," + encodeURIComponent(content);
327 downloadAnchor.click();
328 },
329 getPgn: function() {
330 let pgn = "";
331 pgn += '[Site "vchess.club"]\n';
332 pgn += '[Variant "' + this.game.vname + '"]\n';
333 const gdt = getDate(new Date(this.game.created || Date.now()));
334 pgn += '[Date "' + gdt + '"]\n';
335 pgn += '[White "' + this.game.players[0].name + '"]\n';
336 pgn += '[Black "' + this.game.players[1].name + '"]\n';
337 pgn += '[Fen "' + this.game.fenStart + '"]\n';
338 pgn += '[Result "' + this.game.score + '"]\n';
339 if (!!this.game.id)
340 pgn += '[Url "' + params.serverUrl + '/game/' + this.game.id + '"]\n';
341 if (!!this.game.cadence)
342 pgn += '[Cadence "' + this.game.cadence + '"]\n';
343 pgn += '\n';
344 for (let i = 0; i < this.moves.length; i += 2) {
345 if (i > 0) pgn += " ";
346 // Adjust dots notation for a better display:
347 let fullNotation = getFullNotation(this.moves[i]);
348 if (fullNotation == "...") fullNotation = "..";
349 pgn += (i / 2 + this.firstMoveNumber) + "." + fullNotation;
350 if (i+1 < this.moves.length)
351 pgn += " " + getFullNotation(this.moves[i+1]);
352 }
353 pgn += "\n\n";
354 for (let i = 0; i < this.moves.length; i += 2) {
355 const moveNumber = i / 2 + this.firstMoveNumber;
356 // Skip "dots move", useless for machine reading:
357 if (this.moves[i].notation != "...") {
358 pgn += moveNumber + ".w " +
359 getFullNotation(this.moves[i], "unambiguous") + "\n";
360 }
361 if (i+1 < this.moves.length) {
362 pgn += moveNumber + ".b " +
363 getFullNotation(this.moves[i+1], "unambiguous") + "\n";
364 }
365 }
366 return pgn;
367 },
368 showEndgameMsg: function(message) {
369 this.endgameMessage = message;
370 document.getElementById("modalEog").checked = true;
371 },
372 runAutoplay: function() {
373 if (this.autoplay) {
374 this.autoplay = false;
375 if (this.stackToPlay.length > 0)
376 // Move(s) arrived in-between
377 this.play(this.stackToPlay.pop(), "received");
378 }
379 else if (this.cursor < this.moves.length - 1) {
380 this.autoplay = true;
381 this.play(null, null, null, "autoplay");
382 }
383 },
384 // Animate an elementary move
385 animateMove: function(move, callback) {
386 let startSquare = document.getElementById(getSquareId(move.start));
387 if (!startSquare) return; //shouldn't happen but...
388 let endSquare = document.getElementById(getSquareId(move.end));
389 let rectStart = startSquare.getBoundingClientRect();
390 let rectEnd = endSquare.getBoundingClientRect();
391 let translation = {
392 x: rectEnd.x - rectStart.x,
393 y: rectEnd.y - rectStart.y
394 };
395 let movingPiece = document.querySelector(
396 "#" + getSquareId(move.start) + " > img.piece"
397 );
398 // For some unknown reasons Opera get "movingPiece == null" error
399 // TODO: is it calling 'animate()' twice ? One extra time ?
400 if (!movingPiece) return;
401 const squares = document.getElementsByClassName("board");
402 for (let i = 0; i < squares.length; i++) {
403 let square = squares.item(i);
404 if (square.id != getSquareId(move.start))
405 // HACK for animation:
406 // (with positive translate, image slides "under background")
407 square.style.zIndex = "-1";
408 }
409 movingPiece.style.transform =
410 "translate(" + translation.x + "px," + translation.y + "px)";
411 movingPiece.style.transitionDuration = "0.25s";
412 movingPiece.style.zIndex = "3000";
413 setTimeout(() => {
414 for (let i = 0; i < squares.length; i++)
415 squares.item(i).style.zIndex = "auto";
416 movingPiece.style = {}; //required e.g. for 0-0 with KR swap
417 callback();
418 }, 250);
419 },
420 // For Analyse mode:
421 emitFenIfAnalyze: function() {
422 if (this.game.mode == "analyze") {
423 let fen = this.game.fenStart;
424 if (!!this.lastMove) {
425 if (Array.isArray(this.lastMove)) {
426 const L = this.lastMove.length;
427 fen = this.lastMove[L-1].fen;
428 }
429 else fen = this.lastMove.fen;
430 }
431 this.$emit("fenchange", fen);
432 }
433 },
434 clickSquare: function(square) {
435 // Some variants make use of a single click at specific times:
436 const move = this.vr.doClick(square);
437 if (!!move) this.play(move);
438 },
439 // "light": if gotoMove() or gotoEnd()
440 play: function(move, received, light, autoplay) {
441 // Freeze while choices are shown:
442 if (
443 !!this.$refs["board"].selectedPiece ||
444 this.$refs["board"].choices.length > 0
445 ) {
446 return;
447 }
448 const navigate = !move;
449 // Forbid navigation during autoplay:
450 if (navigate && this.autoplay && !autoplay) return;
451 // Forbid playing outside analyze mode, except if move is received.
452 // Sufficient condition because Board already knows which turn it is.
453 if (
454 this.mode != "analyze" &&
455 !navigate &&
456 !received &&
457 (this.game.score != "*" || this.cursor < this.moves.length - 1)
458 ) {
459 return;
460 }
461 if (!!received) {
462 if (this.autoplay || this.inPlay) {
463 // Received moves while autoplaying are stacked,
464 // and in observed games they could arrive too fast:
465 this.stackToPlay.unshift(move);
466 return;
467 }
468 if (this.mode == "analyze") this.toggleAnalyze();
469 if (this.cursor < this.moves.length - 1)
470 // To play a received move, cursor must be at the end of the game:
471 this.gotoEnd();
472 this.inPlay = true;
473 }
474 // The board may show some possible moves: (TODO: bad solution)
475 this.$refs["board"].resetCurrentAttempt();
476 const playSubmove = (smove) => {
477 smove.notation = this.vr.getNotation(smove);
478 smove.unambiguous = V.GetUnambiguousNotation(smove);
479 this.vr.play(smove);
480 if (this.inMultimove && !!this.lastMove) {
481 if (!Array.isArray(this.lastMove))
482 this.lastMove = [this.lastMove, smove];
483 else this.lastMove.push(smove);
484 }
485 // Is opponent (or me) in check?
486 this.incheck = this.vr.getCheckSquares();
487 if (this.incheck.length > 0) smove.notation += "+";
488 if (!this.inMultimove) {
489 // First sub-move:
490 this.lastMove = smove;
491 // Condition is "!navigate" but we mean "!this.autoplay"
492 if (!navigate) {
493 if (this.cursor < this.moves.length - 1)
494 this.moves = this.moves.slice(0, this.cursor + 1);
495 this.moves.push(smove);
496 }
497 this.inMultimove = true; //potentially
498 this.cursor++;
499 } else if (!navigate) {
500 // Already in the middle of a multi-move
501 const L = this.moves.length;
502 if (!Array.isArray(this.moves[L-1]))
503 this.$set(this.moves, L-1, [this.moves[L-1], smove]);
504 else this.moves[L-1].push(smove);
505 }
506 };
507 const playMove = () => {
508 const animate = (
509 ["all", "highlight"].includes(V.ShowMoves) &&
510 (this.autoplay || !!received)
511 );
512 if (!Array.isArray(move)) move = [move];
513 let moveIdx = 0;
514 let self = this;
515 const initurn = this.vr.turn;
516 (function executeMove() {
517 const smove = move[moveIdx++];
518 // NOTE: condition "smove.start.x >= 0" required for Dynamo,
519 // because second move may be empty. noHighlight condition
520 // is used at least for Chakart.
521 if (animate && smove.start.x >= 0 && !smove.end.noHighlight) {
522 self.animateMove(smove, () => {
523 playSubmove(smove);
524 if (moveIdx < move.length) setTimeout(executeMove, 500);
525 else afterMove(smove, initurn);
526 });
527 } else {
528 playSubmove(smove);
529 if (moveIdx < move.length) executeMove();
530 else afterMove(smove, initurn);
531 }
532 })();
533 };
534 const computeScore = () => {
535 const score = this.vr.getCurrentScore();
536 if (!navigate) {
537 if (["1-0", "0-1"].includes(score)) {
538 if (Array.isArray(this.lastMove)) {
539 const L = this.lastMove.length;
540 this.lastMove[L - 1].notation += "#";
541 }
542 else this.lastMove.notation += "#";
543 }
544 }
545 if (score != "*" && ["analyze", "versus"].includes(this.mode)) {
546 const message = getScoreMessage(score);
547 // Show score on screen
548 this.showEndgameMsg(score + " . " + this.st.tr[message]);
549 }
550 return score;
551 };
552 const afterMove = (smove, initurn) => {
553 if (this.vr.turn != initurn) {
554 // Turn has changed: move is complete
555 if (!smove.fen)
556 // NOTE: only FEN of last sub-move is required (=> setting it here)
557 smove.fen = this.vr.getFen();
558 this.emitFenIfAnalyze();
559 this.inMultimove = false;
560 this.score = computeScore();
561 if (this.autoplay) {
562 if (this.cursor < this.moves.length - 1)
563 setTimeout(() => this.play(null, null, null, "autoplay"), 1000);
564 else {
565 this.autoplay = false;
566 if (this.stackToPlay.length > 0)
567 // Move(s) arrived in-between
568 this.play(this.stackToPlay.pop(), "received");
569 }
570 }
571 if (this.mode != "analyze" && !navigate) {
572 if (!received) {
573 // Post-processing (e.g. computer play).
574 const L = this.moves.length;
575 // NOTE: always emit the score, even in unfinished
576 this.$emit("newmove", this.moves[L-1], { score: this.score });
577 } else {
578 this.inPlay = false;
579 if (this.stackToPlay.length > 0)
580 // Move(s) arrived in-between
581 this.play(this.stackToPlay.pop(), "received");
582 }
583 }
584 }
585 };
586 // NOTE: navigate and received are mutually exclusive
587 if (navigate) {
588 // The move to navigate to is necessarily full:
589 if (this.cursor == this.moves.length - 1) return; //no more moves
590 move = this.moves[this.cursor + 1];
591 if (!this.autoplay) {
592 // Just play the move:
593 if (!Array.isArray(move)) move = [move];
594 for (let i=0; i < move.length; i++) this.vr.play(move[i]);
595 if (!light) {
596 this.lastMove = move;
597 this.incheck = this.vr.getCheckSquares();
598 this.score = computeScore();
599 this.emitFenIfAnalyze();
600 }
601 this.cursor++;
602 return;
603 }
604 }
605 playMove();
606 },
607 cancelCurrentMultimove: function() {
608 const L = this.moves.length;
609 let move = this.moves[L-1];
610 if (!Array.isArray(move)) move = [move];
611 for (let i = move.length - 1; i >= 0; i--) this.vr.undo(move[i]);
612 this.moves.pop();
613 this.cursor--;
614 this.inMultimove = false;
615 },
616 cancelLastMove: function() {
617 // The last played move was canceled (corr game)
618 this.undo();
619 this.moves.pop();
620 },
621 // "light": if gotoMove() or gotoBegin()
622 undo: function(move, light) {
623 if (
624 this.autoplay ||
625 !!this.$refs["board"].selectedPiece ||
626 this.$refs["board"].choices.length > 0
627 ) {
628 return;
629 }
630 this.$refs["board"].resetCurrentAttempt();
631 if (this.inMultimove) {
632 this.cancelCurrentMultimove();
633 this.incheck = this.vr.getCheckSquares();
634 if (this.cursor >= 0) this.lastMove = this.moves[this.cursor];
635 else this.lastMove = null;
636 } else {
637 if (!move) {
638 const minCursor =
639 this.moves.length > 0 && this.moves[0].notation == "..."
640 ? 1
641 : 0;
642 if (this.cursor < minCursor) return; //no more moves
643 move = this.moves[this.cursor];
644 }
645 this.$refs["board"].resetCurrentAttempt();
646 undoMove(move, this.vr);
647 if (light) this.cursor--;
648 else {
649 this.positionCursorTo(this.cursor - 1);
650 this.incheck = this.vr.getCheckSquares();
651 this.emitFenIfAnalyze();
652 }
653 }
654 },
655 gotoMove: function(index) {
656 if (
657 this.autoplay ||
658 !!this.$refs["board"].selectedPiece ||
659 this.$refs["board"].choices.length > 0
660 ) {
661 return;
662 }
663 this.$refs["board"].resetCurrentAttempt();
664 if (this.inMultimove) this.cancelCurrentMultimove();
665 if (index == this.cursor) return;
666 if (index < this.cursor) {
667 while (this.cursor > index)
668 this.undo(null, null, "light");
669 }
670 else {
671 // index > this.cursor)
672 while (this.cursor < index)
673 this.play(null, null, "light");
674 }
675 // NOTE: next line also re-assign cursor, but it's very light
676 this.positionCursorTo(index);
677 this.incheck = this.vr.getCheckSquares();
678 this.emitFenIfAnalyze();
679 },
680 gotoBegin: function() {
681 if (
682 this.autoplay ||
683 !!this.$refs["board"].selectedPiece ||
684 this.$refs["board"].choices.length > 0
685 ) {
686 return;
687 }
688 this.$refs["board"].resetCurrentAttempt();
689 if (this.inMultimove) this.cancelCurrentMultimove();
690 const minCursor =
691 this.moves.length > 0 && this.moves[0].notation == "..."
692 ? 1
693 : 0;
694 while (this.cursor >= minCursor) this.undo(null, null, "light");
695 this.lastMove = (minCursor == 1 ? this.moves[0] : null);
696 this.incheck = this.vr.getCheckSquares();
697 this.emitFenIfAnalyze();
698 },
699 gotoEnd: function() {
700 if (this.cursor == this.moves.length - 1) return;
701 this.gotoMove(this.moves.length - 1);
702 },
703 flip: function() {
704 if (this.$refs["board"].choices.length > 0) return;
705 this.orientation = V.GetOppCol(this.orientation);
706 }
707 }
708 };
709 </script>
710
711 <style lang="sass" scoped>
712 [type="checkbox"]#modalEog+div .card
713 min-height: 45px
714 max-width: 350px
715
716 #baseGame
717 width: 100%
718 &:focus
719 outline: none
720
721 #gameContainer
722 margin-left: auto
723 margin-right: auto
724
725 #downloadDiv
726 display: inline-block
727
728 #controls
729 user-select: none
730 button
731 border: none
732 margin: 0
733 padding-top: 5px
734 padding-bottom: 5px
735
736 p#fenAnalyze
737 margin: 5px
738
739 .in-autoplay
740 background-color: #FACF8C
741
742 img.inline
743 height: 22px
744 padding-top: 5px
745 @media screen and (max-width: 767px)
746 height: 18px
747
748 #turnIndicator
749 text-align: center
750 font-weight: bold
751
752 #boardContainer
753 float: left
754 // TODO: later, maybe, allow movesList of variable width
755 // or e.g. between 250 and 350px (but more complicated)
756
757 #movesList
758 width: 280px
759 float: left
760
761 @media screen and (max-width: 767px)
762 #movesList
763 width: 100%
764 float: none
765 clear: both
766 </style>