.row
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
// Menu (top of page):
- // Left: hall, variants, mygames, forum (ext. link)
+ // Left: hall, variants, mygames
// Right: usermenu, settings, flag
nav
label.drawer-toggle(for="drawerControl")
| {{ st.tr["Variants"] }}
router-link(to="/mygames")
| {{ st.tr["My games"] }}
- a(href="https://forum.vchess.club")
- | {{ st.tr["Forum"] }}
#rightMenu
.clickable(onClick="doClick('modalUser')")
| {{ st.user.id > 0 ? (st.user.name || "@nonymous") : "Login" }}
router-link.menuitem(to="/about") {{ st.tr["About"] }}
p.clickable(onClick="doClick('modalContact')")
| {{ st.tr["Contact"] }}
+ a.menuitem(href="https://forum.vchess.club")
+ | {{ st.tr["Forum"] }}
</template>
<script>
justify-content: center
& > .menuitem
display: inline-block
- margin: 0 10px 0 0
+ margin: 0 10px
&:link
color: #2c3e50
&:visited, &:hover
text-decoration: none
& > p
display: inline-block
- margin: 0 0 0 10px
+ margin: 0 10px
@media screen and (max-width: 767px)
footer
| {{ st.tr["Analyze"] }}
.col-sm-12.col-md-3
MoveList(v-if="showMoves" :score="game.score" :message="game.scoreMsg"
- :moves="moves" :cursor="cursor" @goto-move="gotoMove")
+ :firstNum="firstMoveNumber" :moves="moves" :cursor="cursor"
+ @goto-move="gotoMove")
</template>
<script>
moves: [],
cursor: -1, //index of the move just played
lastMove: null,
+ firstMoveNumber: 0, //for printing
};
},
watch: {
// Post-processing: decorate each move with color + current FEN:
// (to be able to jump to any position quickly)
let vr_tmp = new V(this.game.fenStart); //vr is already at end of game
+ this.firstMoveNumber =
+ Math.floor(V.ParseFen(this.game.fenStart).movesCount / 2);
this.moves.forEach(move => {
// NOTE: this is doing manually what play() function below achieve,
// but in a lighter "fast-forward" way
this.lastMove = this.moves[index];
},
gotoBegin: function() {
+ if (this.cursor == -1)
+ return;
this.vr.re_init(this.game.fenStart);
if (this.moves.length > 0 && this.moves[0].notation == "...")
{
}
},
gotoEnd: function() {
+ if (this.cursor == this.moves.length - 1)
+ return;
this.gotoMove(this.moves.length-1);
},
flip: function() {
table#movesList
tbody
tr(v-for="moveIdx in evenNumbers")
- td {{ moveIdx / 2 + 1 }}
+ td {{ firstNum + moveIdx / 2 + 1 }}
td(:class="{'highlight-lm': cursor == moveIdx}"
data-label="White move" @click="() => gotoMove(moveIdx)")
| {{ moves[moveIdx].notation }}
// Component for moves list on the right
export default {
name: 'my-move-list',
- props: ["moves","cursor","score","message"],
+ props: ["moves","cursor","score","message","firstNum"],
watch: {
cursor: function(newValue) {
if (newValue < 0)
main
.row
.col-sm-12
- #fenDiv(v-if="!!vr") {{ vr.getFen() }}
+ #fenDiv
+ input#fen(v-model="curFen" @input="adjustFenSize")
+ button(@click="gotoFen") Go
.row
.col-sm-12.col-md-10.col-md-offset-1
BaseGame(:game="game" :vr="vr" ref="basegame")
mode: "analyze"
},
vr: null, //"variant rules" object initialized from FEN
+ curFen: "",
//people: [], //players + observers //TODO later: interactive analyze...
};
},
this.gameRef.vname = to.params["vname"];
this.loadGame();
},
+ "vr.movesCount": function(fen) {
+ this.curFen = this.vr.getFen();
+ this.adjustFenSize();
+ },
},
created: function() {
this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
this.gameRef.vname = this.$route.params["vname"];
- this.loadGame();
+ this.initialize(this.loadGame);
},
methods: {
- loadGame: async function() {
+ initialize: async function(callback) {
+ // Obtain VariantRules object
+ const vModule = await import("@/variants/" + this.gameRef.vname + ".js");
+ window.V = vModule.VariantRules;
+ callback();
+ },
+ loadGame: function() {
this.game.vname = this.gameRef.vname;
this.game.fen = this.gameRef.fen;
- const vModule = await import("@/variants/" + this.game.vname + ".js");
- window.V = vModule.VariantRules;
+ this.curFen = this.game.fen;
+ this.adjustFenSize();
this.vr = new V(this.game.fen);
- // fenStart initialized in the end, after definition of V,
- // because it triggers a reset on BaseGame component.
this.$set(this.game, "fenStart", this.gameRef.fen); //TODO: Vue3...
},
+ adjustFenSize: function() {
+ let fenInput = document.getElementById("fen");
+ fenInput.style.width = this.curFen.length + "ch";
+ },
+ gotoFen: function() {
+ this.gameRef.fen = this.curFen;
+ this.loadGame();
+ },
},
};
</script>
-<style lang="sass">
-// TODO
+<style lang="sass" scoped>
+#fenDiv
+ text-align: center
</style>
.row
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
.button-group
- button(@click="clickReadRules") Read the rules
+ button(@click="clickReadRules") Rules
button(v-show="!gameInProgress" @click="() => startGame('auto')")
- | Observe a sample game
+ | Sample game
button(v-show="!gameInProgress" @click="() => startGame('versus')")
- | Beat the computer!
+ | Practice!
button(v-show="gameInProgress" @click="() => stopGame()")
| Stop game
+ button(@click="gotoAnalyze") Analyze
.section-content(v-show="display=='rules'" v-html="content")
ComputerGame(v-show="display=='computer'" :game-info="gameInfo"
@game-over="stopGame" @game-stopped="gameStopped")
gameStopped: function() {
this.gameInProgress = false;
},
+ gotoAnalyze: function() {
+ this.$router.push("/analyze/" + this.gameInfo.vname
+ + "/?fen=" + V.GenRandInitFen());
+ },
},
};
</script>