projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Parameters adjustments + cosmetics
[vchess.git]
/
client
/
src
/
views
/
Rules.vue
diff --git
a/client/src/views/Rules.vue
b/client/src/views/Rules.vue
index
4edc428
..
f196e35
100644
(file)
--- a/
client/src/views/Rules.vue
+++ b/
client/src/views/Rules.vue
@@
-3,42
+3,44
@@
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
.button-group
button(@click="display='rules'") Read the rules
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
.button-group
button(@click="display='rules'") Read the rules
- button(v-show="!gameInProgress" @click="
watchComputerGame
")
+ button(v-show="!gameInProgress" @click="
() => startGame('auto')
")
| Observe a sample game
| Observe a sample game
- button(v-show="!gameInProgress" @click="
playAgainstComputer
")
+ button(v-show="!gameInProgress" @click="
() => startGame('versus')
")
| Beat the computer!
button(v-show="gameInProgress" @click="stopGame")
| Stop game
.section-content(v-show="display=='rules'" v-html="content")
| Beat the computer!
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'" :game-info="gameInfo"
@computer-think="gameInProgress=false" @game-over="stopGame")
</template>
<script>
@computer-think="gameInProgress=false" @game-over="stopGame")
</template>
<script>
-import
Game from "@/components/
Game.vue";
+import
ComputerGame from "@/components/Computer
Game.vue";
import { store } from "@/store";
import { getDiagram } from "@/utils/printDiagram";
import { store } from "@/store";
import { getDiagram } from "@/utils/printDiagram";
+
export default {
name: 'my-rules',
components: {
export default {
name: 'my-rules',
components: {
- Game,
+
Computer
Game,
},
data: function() {
return {
st: store.state,
},
data: function() {
return {
st: store.state,
- variant: {id: 0, name: "_unknown"}, //...yet
content: "",
display: "rules",
content: "",
display: "rules",
- mode: "computer",
- subMode: "", //'auto' for game CPU vs CPU
gameInProgress: false,
gameInProgress: false,
- mycolor: "w",
- fen: "",
+ // variables passed to ComputerGame:
+ gameInfo: {
+ vname: "_unknown",
+ mode: "versus",
+ fen: "",
+ userStop: false,
+ }
};
},
watch: {
};
},
watch: {
-
$route
: function(newRoute) {
+
"$route"
: function(newRoute) {
this.tryChangeVariant(newRoute.params["vname"]);
},
},
this.tryChangeVariant(newRoute.params["vname"]);
},
},
@@
-57,15
+59,9
@@
export default {
};
},
tryChangeVariant: async function(vname) {
};
},
tryChangeVariant: async function(vname) {
- if (vname == "_unknown")
+ if (
!vname ||
vname == "_unknown")
return;
return;
- if (this.st.variants.length > 0)
- {
- const idxOfVar = this.st.variants.findIndex(e => e.name == vname);
- this.variant = this.st.variants[idxOfVar];
- }
- else
- this.variant.name = vname;
+ this.gameInfo.vname = vname;
const vModule = await import("@/variants/" + vname + ".js");
window.V = vModule.VariantRules;
// Method to replace diagrams in loaded HTML
const vModule = await import("@/variants/" + vname + ".js");
window.V = vModule.VariantRules;
// Method to replace diagrams in loaded HTML
@@
-76,27
+72,24
@@
export default {
// (AJAX) Request to get rules content (plain text, HTML)
this.content =
require("raw-loader!@/rules/" + vname + "/" + this.st.lang + ".pug")
// (AJAX) Request to get rules content (plain text, HTML)
this.content =
require("raw-loader!@/rules/" + vname + "/" + this.st.lang + ".pug")
+ // Next two lines fix a weird issue after last update (2019-11)
+ .replace(/\\[n"]/g, " ")
+ .replace('module.exports = "', '').replace(/"$/, "")
.replace(/(fen:)([^:]*):/g, replaceByDiag);
},
.replace(/(fen:)([^:]*):/g, replaceByDiag);
},
- startGame: function() {
+ startGame: function(
mode
) {
if (this.gameInProgress)
return;
this.gameInProgress = true;
if (this.gameInProgress)
return;
this.gameInProgress = true;
- this.mode = "computer";
this.display = "computer";
this.display = "computer";
- this.fen = V.GenRandInitFen();
+ this.gameInfo.mode = mode;
+ this.gameInfo.userStop = false;
+ this.gameInfo.fen = V.GenRandInitFen();
},
stopGame: function() {
this.gameInProgress = false;
},
stopGame: function() {
this.gameInProgress = false;
- this.mode = "analyze";
- },
- playAgainstComputer: function() {
- this.subMode = "";
- this.startGame();
- },
- watchComputerGame: function() {
- this.subMode = "auto";
- this.startGame();
+ this.gameInfo.userStop = true;
+ this.gameInfo.mode = "analyze";
},
},
};
},
},
};
@@
-139,34
+132,34
@@
figure.diagram-container
padding-top: 5px
font-size: 0.8em
padding-top: 5px
font-size: 0.8em
-
p.boxed
-
background-color: #FFCC66
-
padding: 5px
+p.boxed
+ background-color: #FFCC66
+ padding: 5px
-
.stageDelimiter
-
color: purple
+.stageDelimiter
+ color: purple
-
// To show (new) pieces, and/or there values...
-
figure.showPieces > img
-
width: 50px
+// To show (new) pieces, and/or there values...
+figure.showPieces > img
+ width: 50px
-
figure.showPieces > figcaption
-
color: #6C6C6C
+figure.showPieces > figcaption
+ color: #6C6C6C
-
.section-title
-
padding: 0
+.section-title
+ padding: 0
-
.section-title > h4
-
padding: 5px
+.section-title > h4
+ padding: 5px
-
ol, ul:not(.browser-default)
-
padding-left: 20px
+ol, ul:not(.browser-default)
+ padding-left: 20px
-
ul:not(.browser-default)
-
margin-top: 5px
+ul:not(.browser-default)
+ margin-top: 5px
-
ul:not(.browser-default) > li
-
list-style-type: disc
+ul:not(.browser-default) > li
+ list-style-type: disc
.light-square-diag
background-color: #e5e5ca
.light-square-diag
background-color: #e5e5ca