87d18aba804f13f70e63f3012320cbb17f865c6c
[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) this.incheck = checkSquares;
256 });
257 this.score = this.vr.getCurrentScore();
258 if (["1-0", "0-1"].includes(this.score)) m.notation += "#";
259 });
260 }
261 if (firstMoveColor == "b") {
262 // 'start' & 'end' is required for Board component
263 this.moves.unshift({
264 notation: "...",
265 unambiguous: "...",
266 start: { x: -1, y: -1 },
267 end: { x: -1, y: -1 },
268 fen: game.fenStart
269 });
270 L++;
271 }
272 this.positionCursorTo(L - 1);
273 },
274 positionCursorTo: function(index) {
275 this.cursor = index;
276 // Note: last move in moves array might be a multi-move
277 if (index >= 0) this.lastMove = this.moves[index];
278 else this.lastMove = null;
279 },
280 toggleAnalyze: function() {
281 // Freeze while choices are shown (and autoplay has priority)
282 if (
283 this.inPlay ||
284 this.$refs["board"].choices.length > 0 ||
285 this.autoplay
286 ) {
287 return;
288 }
289 if (this.mode != "analyze") {
290 // Enter analyze mode:
291 this.gameMode = this.mode; //was not 'analyze'
292 this.mode = "analyze";
293 if (this.inMultimove) this.cancelCurrentMultimove();
294 this.gameCursor = this.cursor;
295 this.gameMoves = JSON.parse(JSON.stringify(this.moves));
296 document.getElementById("analyzeBtn").classList.add("active");
297 }
298 else {
299 // Exit analyze mode:
300 this.mode = this.gameMode;
301 this.cursor = this.gameCursor;
302 this.moves = this.gameMoves;
303 let fen = this.game.fenStart;
304 if (this.cursor >= 0) {
305 let mv = this.moves[this.cursor];
306 if (!Array.isArray(mv)) mv = [mv];
307 fen = mv[mv.length-1].fen;
308 }
309 this.vr = new V(fen);
310 this.inMultimove = false; //in case of
311 this.$refs["board"].resetCurrentAttempt(); //also in case of
312 this.incheck = this.vr.getCheckSquares();
313 if (this.cursor >= 0) this.lastMove = this.moves[this.cursor];
314 else this.lastMove = null;
315 document.getElementById("analyzeBtn").classList.remove("active");
316 }
317 },
318 download: function() {
319 const content = this.getPgn();
320 // Prepare and trigger download link
321 let downloadAnchor = document.getElementById("download");
322 downloadAnchor.setAttribute("download", "game.pgn");
323 downloadAnchor.href =
324 "data:text/plain;charset=utf-8," + encodeURIComponent(content);
325 downloadAnchor.click();
326 },
327 getPgn: function() {
328 let pgn = "";
329 pgn += '[Site "vchess.club"]\n';
330 pgn += '[Variant "' + this.game.vname + '"]\n';
331 const gdt = getDate(new Date(this.game.created || Date.now()));
332 pgn += '[Date "' + gdt + '"]\n';
333 pgn += '[White "' + this.game.players[0].name + '"]\n';
334 pgn += '[Black "' + this.game.players[1].name + '"]\n';
335 pgn += '[Fen "' + this.game.fenStart + '"]\n';
336 pgn += '[Result "' + this.game.score + '"]\n';
337 if (!!this.game.id)
338 pgn += '[Url "' + params.serverUrl + '/game/' + this.game.id + '"]\n';
339 if (!!this.game.cadence)
340 pgn += '[Cadence "' + this.game.cadence + '"]\n';
341 pgn += '\n';
342 for (let i = 0; i < this.moves.length; i += 2) {
343 if (i > 0) pgn += " ";
344 // Adjust dots notation for a better display:
345 let fullNotation = getFullNotation(this.moves[i]);
346 if (fullNotation == "...") fullNotation = "..";
347 pgn += (i / 2 + this.firstMoveNumber) + "." + fullNotation;
348 if (i+1 < this.moves.length)
349 pgn += " " + getFullNotation(this.moves[i+1]);
350 }
351 pgn += "\n\n";
352 for (let i = 0; i < this.moves.length; i += 2) {
353 const moveNumber = i / 2 + this.firstMoveNumber;
354 // Skip "dots move", useless for machine reading:
355 if (this.moves[i].notation != "...") {
356 pgn += moveNumber + ".w " +
357 getFullNotation(this.moves[i], "unambiguous") + "\n";
358 }
359 if (i+1 < this.moves.length) {
360 pgn += moveNumber + ".b " +
361 getFullNotation(this.moves[i+1], "unambiguous") + "\n";
362 }
363 }
364 return pgn;
365 },
366 showEndgameMsg: function(message) {
367 this.endgameMessage = message;
368 document.getElementById("modalEog").checked = true;
369 },
370 runAutoplay: function() {
371 if (this.autoplay) {
372 this.autoplay = false;
373 if (this.stackToPlay.length > 0)
374 // Move(s) arrived in-between
375 this.play(this.stackToPlay.pop(), "received");
376 }
377 else if (this.cursor < this.moves.length - 1) {
378 this.autoplay = true;
379 this.play(null, null, null, "autoplay");
380 }
381 },
382 // Animate an elementary move
383 animateMove: function(move, callback) {
384 let startSquare = document.getElementById(getSquareId(move.start));
385 if (!startSquare) return; //shouldn't happen but...
386 let endSquare = document.getElementById(getSquareId(move.end));
387 let rectStart = startSquare.getBoundingClientRect();
388 let rectEnd = endSquare.getBoundingClientRect();
389 let translation = {
390 x: rectEnd.x - rectStart.x,
391 y: rectEnd.y - rectStart.y
392 };
393 let movingPiece = document.querySelector(
394 "#" + getSquareId(move.start) + " > img.piece"
395 );
396 // For some unknown reasons Opera get "movingPiece == null" error
397 // TODO: is it calling 'animate()' twice ? One extra time ?
398 if (!movingPiece) return;
399 const squares = document.getElementsByClassName("board");
400 for (let i = 0; i < squares.length; i++) {
401 let square = squares.item(i);
402 if (square.id != getSquareId(move.start))
403 // HACK for animation:
404 // (with positive translate, image slides "under background")
405 square.style.zIndex = "-1";
406 }
407 movingPiece.style.transform =
408 "translate(" + translation.x + "px," + translation.y + "px)";
409 movingPiece.style.transitionDuration = "0.25s";
410 movingPiece.style.zIndex = "3000";
411 setTimeout(() => {
412 for (let i = 0; i < squares.length; i++)
413 squares.item(i).style.zIndex = "auto";
414 movingPiece.style = {}; //required e.g. for 0-0 with KR swap
415 callback();
416 }, 250);
417 },
418 // For Analyse mode:
419 emitFenIfAnalyze: function() {
420 if (this.game.mode == "analyze") {
421 let fen = this.game.fenStart;
422 if (!!this.lastMove) {
423 if (Array.isArray(this.lastMove)) {
424 const L = this.lastMove.length;
425 fen = this.lastMove[L-1].fen;
426 }
427 else fen = this.lastMove.fen;
428 }
429 this.$emit("fenchange", fen);
430 }
431 },
432 clickSquare: function(square) {
433 // Some variants make use of a single click at specific times:
434 const move = this.vr.doClick(square);
435 if (!!move) this.play(move);
436 },
437 // "light": if gotoMove() or gotoEnd()
438 play: function(move, received, light, autoplay) {
439 // Freeze while choices are shown:
440 if (
441 !!this.$refs["board"].selectedPiece ||
442 this.$refs["board"].choices.length > 0
443 ) {
444 return;
445 }
446 const navigate = !move;
447 // Forbid navigation during autoplay:
448 if (navigate && this.autoplay && !autoplay) return;
449 // Forbid playing outside analyze mode, except if move is received.
450 // Sufficient condition because Board already knows which turn it is.
451 if (
452 this.mode != "analyze" &&
453 !navigate &&
454 !received &&
455 (this.game.score != "*" || this.cursor < this.moves.length - 1)
456 ) {
457 return;
458 }
459 if (!!received) {
460 if (this.autoplay || this.inPlay) {
461 // Received moves while autoplaying are stacked,
462 // and in observed games they could arrive too fast:
463 this.stackToPlay.unshift(move);
464 return;
465 }
466 if (this.mode == "analyze") this.toggleAnalyze();
467 if (this.cursor < this.moves.length - 1)
468 // To play a received move, cursor must be at the end of the game:
469 this.gotoEnd();
470 this.inPlay = true;
471 }
472 // The board may show some possible moves: (TODO: bad solution)
473 this.$refs["board"].resetCurrentAttempt();
474 const playSubmove = (smove) => {
475 smove.notation = this.vr.getNotation(smove);
476 smove.unambiguous = V.GetUnambiguousNotation(smove);
477 this.vr.play(smove);
478 if (this.inMultimove && !!this.lastMove) {
479 if (!Array.isArray(this.lastMove))
480 this.lastMove = [this.lastMove, smove];
481 else this.lastMove.push(smove);
482 }
483 // Is opponent (or me) in check?
484 this.incheck = this.vr.getCheckSquares();
485 if (this.incheck.length > 0) smove.notation += "+";
486 if (!this.inMultimove) {
487 // First sub-move:
488 this.lastMove = smove;
489 // Condition is "!navigate" but we mean "!this.autoplay"
490 if (!navigate) {
491 if (this.cursor < this.moves.length - 1)
492 this.moves = this.moves.slice(0, this.cursor + 1);
493 this.moves.push(smove);
494 }
495 this.inMultimove = true; //potentially
496 this.cursor++;
497 } else if (!navigate) {
498 // Already in the middle of a multi-move
499 const L = this.moves.length;
500 if (!Array.isArray(this.moves[L-1]))
501 this.$set(this.moves, L-1, [this.moves[L-1], smove]);
502 else this.moves[L-1].push(smove);
503 }
504 };
505 const playMove = () => {
506 const animate = (
507 ["all", "highlight"].includes(V.ShowMoves) &&
508 (this.autoplay || !!received)
509 );
510 if (!Array.isArray(move)) move = [move];
511 let moveIdx = 0;
512 let self = this;
513 const initurn = this.vr.turn;
514 (function executeMove() {
515 const smove = move[moveIdx++];
516 // NOTE: condition "smove.start.x >= 0" required for Dynamo,
517 // because second move may be empty. noHighlight condition
518 // is used at least for Chakart.
519 if (animate && smove.start.x >= 0 && !smove.end.noHighlight) {
520 self.animateMove(smove, () => {
521 playSubmove(smove);
522 if (moveIdx < move.length) setTimeout(executeMove, 500);
523 else afterMove(smove, initurn);
524 });
525 } else {
526 playSubmove(smove);
527 if (moveIdx < move.length) executeMove();
528 else afterMove(smove, initurn);
529 }
530 })();
531 };
532 const computeScore = () => {
533 const score = this.vr.getCurrentScore();
534 if (!navigate) {
535 if (["1-0", "0-1"].includes(score)) {
536 if (Array.isArray(this.lastMove)) {
537 const L = this.lastMove.length;
538 this.lastMove[L - 1].notation += "#";
539 }
540 else this.lastMove.notation += "#";
541 }
542 }
543 if (score != "*" && ["analyze", "versus"].includes(this.mode)) {
544 const message = getScoreMessage(score);
545 // Show score on screen
546 this.showEndgameMsg(score + " . " + this.st.tr[message]);
547 }
548 return score;
549 };
550 const afterMove = (smove, initurn) => {
551 if (this.vr.turn != initurn) {
552 // Turn has changed: move is complete
553 if (!smove.fen)
554 // NOTE: only FEN of last sub-move is required (=> setting it here)
555 smove.fen = this.vr.getFen();
556 this.emitFenIfAnalyze();
557 this.inMultimove = false;
558 this.score = computeScore();
559 if (this.autoplay) {
560 if (this.cursor < this.moves.length - 1)
561 setTimeout(() => this.play(null, null, null, "autoplay"), 1000);
562 else {
563 this.autoplay = false;
564 if (this.stackToPlay.length > 0)
565 // Move(s) arrived in-between
566 this.play(this.stackToPlay.pop(), "received");
567 }
568 }
569 if (this.mode != "analyze" && !navigate) {
570 if (!received) {
571 // Post-processing (e.g. computer play).
572 const L = this.moves.length;
573 // NOTE: always emit the score, even in unfinished
574 this.$emit("newmove", this.moves[L-1], { score: this.score });
575 } else {
576 this.inPlay = false;
577 if (this.stackToPlay.length > 0)
578 // Move(s) arrived in-between
579 this.play(this.stackToPlay.pop(), "received");
580 }
581 }
582 }
583 };
584 // NOTE: navigate and received are mutually exclusive
585 if (navigate) {
586 // The move to navigate to is necessarily full:
587 if (this.cursor == this.moves.length - 1) return; //no more moves
588 move = this.moves[this.cursor + 1];
589 if (!this.autoplay) {
590 // Just play the move:
591 if (!Array.isArray(move)) move = [move];
592 for (let i=0; i < move.length; i++) this.vr.play(move[i]);
593 if (!light) {
594 this.lastMove = move;
595 this.incheck = this.vr.getCheckSquares();
596 this.score = computeScore();
597 this.emitFenIfAnalyze();
598 }
599 this.cursor++;
600 return;
601 }
602 }
603 playMove();
604 },
605 cancelCurrentMultimove: function() {
606 const L = this.moves.length;
607 let move = this.moves[L-1];
608 if (!Array.isArray(move)) move = [move];
609 for (let i = move.length - 1; i >= 0; i--) this.vr.undo(move[i]);
610 this.moves.pop();
611 this.cursor--;
612 this.inMultimove = false;
613 },
614 cancelLastMove: function() {
615 // The last played move was canceled (corr game)
616 this.undo();
617 this.moves.pop();
618 },
619 // "light": if gotoMove() or gotoBegin()
620 undo: function(move, light) {
621 if (
622 this.autoplay ||
623 !!this.$refs["board"].selectedPiece ||
624 this.$refs["board"].choices.length > 0
625 ) {
626 return;
627 }
628 this.$refs["board"].resetCurrentAttempt();
629 if (this.inMultimove) {
630 this.cancelCurrentMultimove();
631 this.incheck = this.vr.getCheckSquares();
632 if (this.cursor >= 0) this.lastMove = this.moves[this.cursor];
633 else this.lastMove = null;
634 } else {
635 if (!move) {
636 const minCursor =
637 this.moves.length > 0 && this.moves[0].notation == "..."
638 ? 1
639 : 0;
640 if (this.cursor < minCursor) return; //no more moves
641 move = this.moves[this.cursor];
642 }
643 this.$refs["board"].resetCurrentAttempt();
644 undoMove(move, this.vr);
645 if (light) this.cursor--;
646 else {
647 this.positionCursorTo(this.cursor - 1);
648 this.incheck = this.vr.getCheckSquares();
649 this.emitFenIfAnalyze();
650 }
651 }
652 },
653 gotoMove: function(index) {
654 if (
655 this.autoplay ||
656 !!this.$refs["board"].selectedPiece ||
657 this.$refs["board"].choices.length > 0
658 ) {
659 return;
660 }
661 this.$refs["board"].resetCurrentAttempt();
662 if (this.inMultimove) this.cancelCurrentMultimove();
663 if (index == this.cursor) return;
664 if (index < this.cursor) {
665 while (this.cursor > index)
666 this.undo(null, null, "light");
667 }
668 else {
669 // index > this.cursor)
670 while (this.cursor < index)
671 this.play(null, null, "light");
672 }
673 // NOTE: next line also re-assign cursor, but it's very light
674 this.positionCursorTo(index);
675 this.incheck = this.vr.getCheckSquares();
676 this.emitFenIfAnalyze();
677 },
678 gotoBegin: function() {
679 if (
680 this.autoplay ||
681 !!this.$refs["board"].selectedPiece ||
682 this.$refs["board"].choices.length > 0
683 ) {
684 return;
685 }
686 this.$refs["board"].resetCurrentAttempt();
687 if (this.inMultimove) this.cancelCurrentMultimove();
688 const minCursor =
689 this.moves.length > 0 && this.moves[0].notation == "..."
690 ? 1
691 : 0;
692 while (this.cursor >= minCursor) this.undo(null, null, "light");
693 this.lastMove = (minCursor == 1 ? this.moves[0] : null);
694 this.incheck = this.vr.getCheckSquares();
695 this.emitFenIfAnalyze();
696 },
697 gotoEnd: function() {
698 if (this.cursor == this.moves.length - 1) return;
699 this.gotoMove(this.moves.length - 1);
700 },
701 flip: function() {
702 if (this.$refs["board"].choices.length > 0) return;
703 this.orientation = V.GetOppCol(this.orientation);
704 }
705 }
706 };
707 </script>
708
709 <style lang="sass" scoped>
710 [type="checkbox"]#modalEog+div .card
711 min-height: 45px
712 max-width: 350px
713
714 #baseGame
715 width: 100%
716 &:focus
717 outline: none
718
719 #gameContainer
720 margin-left: auto
721 margin-right: auto
722
723 #downloadDiv
724 display: inline-block
725
726 #controls
727 user-select: none
728 button
729 border: none
730 margin: 0
731 padding-top: 5px
732 padding-bottom: 5px
733
734 p#fenAnalyze
735 margin: 5px
736
737 .in-autoplay
738 background-color: #FACF8C
739
740 img.inline
741 height: 22px
742 padding-top: 5px
743 @media screen and (max-width: 767px)
744 height: 18px
745
746 #turnIndicator
747 text-align: center
748 font-weight: bold
749
750 #boardContainer
751 float: left
752 // TODO: later, maybe, allow movesList of variable width
753 // or e.g. between 250 and 350px (but more complicated)
754
755 #movesList
756 width: 280px
757 float: left
758
759 @media screen and (max-width: 767px)
760 #movesList
761 width: 100%
762 float: none
763 clear: both
764 </style>