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" :vname="variant.name"
@computer-think="gameInProgress=false" @game-over="stopGame")
</template>
<script>
-import Game from "@/components/Game.vue";
+import ComputerGame from "@/components/ComputerGame.vue";
import { store } from "@/store";
import { getDiagram } from "@/utils/printDiagram";
export default {
name: 'my-rules',
components: {
- Game,
+ ComputerGame,
},
data: function() {
return {
variant: {id: 0, name: "_unknown"}, //...yet
content: "",
display: "rules",
- mode: "computer",
- subMode: "", //'auto' for game CPU vs CPU
+ mode: "versus",
gameInProgress: false,
mycolor: "w",
fen: "",
};
},
watch: {
- $route: function(newRoute) {
+ "$route": function(newRoute) {
this.tryChangeVariant(newRoute.params["vname"]);
},
},
};
},
tryChangeVariant: async function(vname) {
- if (vname == "_unknown")
+ if (!vname || vname == "_unknown")
return;
if (this.st.variants.length > 0)
{
if (this.gameInProgress)
return;
this.gameInProgress = true;
- this.mode = "computer";
this.display = "computer";
this.fen = V.GenRandInitFen();
},
this.mode = "analyze";
},
playAgainstComputer: function() {
- this.subMode = "";
+ this.mode = "versus";
this.startGame();
},
watchComputerGame: function() {
- this.subMode = "auto";
+ this.mode = "auto";
this.startGame();
},
},