From: Benjamin Auder Date: Fri, 29 Mar 2019 18:15:21 +0000 (+0100) Subject: Refactoring: BaseGame, Game, ComputerGame (ProblemGame?) X-Git-Url: https://git.auder.net/assets/img/current/git-favicon.png?a=commitdiff_plain;h=a6088c906bbe6fae95707dc7028e45023fe39981;p=vchess.git Refactoring: BaseGame, Game, ComputerGame (ProblemGame?) --- diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue new file mode 100644 index 00000000..ceadcd3a --- /dev/null +++ b/client/src/components/BaseGame.vue @@ -0,0 +1,257 @@ + + + diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 8392cfe4..8b1055bd 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -11,9 +11,8 @@ export default { name: 'my-board', // Last move cannot be guessed from here, and is required to highlight squares // vr: object to check moves, print board... - // mode: HH, HC or analyze // userColor: for mode HH or HC - props: ["vr","lastMove","mode","orientation","userColor","vname"], + props: ["vr","lastMove","analyze","orientation","userColor","vname"], data: function () { return { hints: (!localStorage["hints"] ? true : localStorage["hints"] === "1"), @@ -100,7 +99,7 @@ export default { let cj = (this.orientation=='w' ? j : sizeY-j-1); let elems = []; if (this.vr.board[ci][cj] != V.EMPTY && (this.vname!="Dark" - || this.gameOver || this.mode == "analyze" + || this.gameOver || this.analyze || this.vr.enlightened[this.userColor][ci][cj])) { elems.push( @@ -146,8 +145,7 @@ export default { 'dark-square': (i+j)%2==1, [this.bcolor]: true, 'in-shadow': this.vname=="Dark" && !this.gameOver - && this.mode != "analyze" - && !this.vr.enlightened[this.userColor][ci][cj], + && !this.analyze && !this.vr.enlightened[this.userColor][ci][cj], 'highlight': showLight && !!lm && lm.end.x == ci && lm.end.y == cj, 'incheck': showLight && incheckSq[ci][cj], }, @@ -293,9 +291,7 @@ export default { this.selectedPiece.style.zIndex = 3000; const startSquare = getSquareFromId(e.target.parentNode.id); this.possibleMoves = []; - const color = this.mode=="analyze" || this.gameOver - ? this.vr.turn - : this.userColor; + const color = (this.analyze || this.gameOver ? this.vr.turn : this.userColor); if (this.vr.canIplay(color,startSquare)) this.possibleMoves = this.vr.getPossibleMovesFrom(startSquare); // Next line add moving piece just after current image diff --git a/client/src/components/ComputerGame.vue b/client/src/components/ComputerGame.vue new file mode 100644 index 00000000..a15686fd --- /dev/null +++ b/client/src/components/ComputerGame.vue @@ -0,0 +1,103 @@ + + + diff --git a/client/src/components/Game.vue b/client/src/components/Game.vue deleted file mode 100644 index 2a74a072..00000000 --- a/client/src/components/Game.vue +++ /dev/null @@ -1,543 +0,0 @@ - - - diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 151c347b..d0e601ca 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -9,3 +9,238 @@ pareil quand quelqu'un reco. (c'est assez rudimentaire et écoute trop de messages, mais dans un premier temps...) // TODO: [in game] send move + elapsed time (in milliseconds); in case of "lastate" message too --> + + + diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 0fd8322c..97df499a 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -598,6 +598,7 @@ export default { localStorage["players"] = JSON.stringify(gameInfo.players); if (this.st.settings.sound >= 1) new Audio("/sounds/newgame.mp3").play().catch(err => {}); + // TODO: redirect to game }, }, }; diff --git a/client/src/views/Rules.vue b/client/src/views/Rules.vue index 4edc428f..c92e0abe 100644 --- a/client/src/views/Rules.vue +++ b/client/src/views/Rules.vue @@ -10,19 +10,19 @@ button(v-show="gameInProgress" @click="stopGame") | Stop game .section-content(v-show="display=='rules'" v-html="content") - Game(v-show="display=='computer'" :gid-or-fen="fen" - :mode="mode" :sub-mode="subMode" :variant="variant" + ComputerGame(v-show="display=='computer'" + :fen="fen" :mode="mode" :variant="variant" @computer-think="gameInProgress=false" @game-over="stopGame")