h3#eogMessage.section {{ endgameMessage }}
#gameContainer
#boardContainer
- Board(:vr="vr" :last-move="lastMove" :analyze="game.mode=='analyze'"
+ Board(:vr="vr" :last-move="lastMove" :analyze="analyze"
:user-color="game.mycolor" :orientation="orientation"
:vname="game.vname" @play-move="play")
- #turnIndicator(v-if="game.vname=='Dark' && game.mode!='analyze'")
+ #turnIndicator(v-if="game.vname=='Dark' && game.score=='*'")
| {{ turn }}
#controls
button(@click="gotoBegin") <<
button(@click="() => play()") >
button(@click="gotoEnd") >>
#pgnDiv
- a#download(href="#")
- button(@click="download") {{ st.tr["Download PGN"] }}
+ div(v-if="game.vname!='Dark' || game.score!='*'")
+ a#download(href="#")
+ button(@click="download") {{ st.tr["Download PGN"] }}
button(v-if="game.vname!='Dark' && game.mode!='analyze'"
@click="analyzePosition")
| {{ st.tr["Analyze"] }}
- button(@click="showRules") {{ st.tr["Rules"] }}
+ // NOTE: rather ugly hack to avoid showing twice "rules" link...
+ button(v-if="!$route.path.match('/variants/')" @click="showRules")
+ | {{ st.tr["Rules"] }}
#movesList
MoveList(v-if="showMoves" :score="game.score" :message="game.scoreMsg"
:firstNum="firstMoveNumber" :moves="moves" :cursor="cursor"
},
computed: {
showMoves: function() {
- return this.game.vname != "Dark" || this.game.mode=="analyze";
+ return this.game.vname != "Dark" || this.game.score != "*";
},
turn: function() {
let color = "";
color = "Black";
return color + " turn";
},
+ analyze: function() {
+ return this.game.mode=="analyze" ||
+ // From Board viewpoint, a finished Dark game == analyze (TODO: unclear)
+ (this.game.vname == "Dark" && this.game.score != "*");
+ },
},
created: function() {
if (!!this.game.fenStart)
}
},
handleScroll: function(e) {
- if (this.game.mode == "analyze" || this.game.score != "*")
+ // NOTE: since game.mode=="analyze" => no score, next condition is enough
+ if (this.game.score != "*")
{
e.preventDefault();
if (e.deltaY < 0)
// Forbid playing outside analyze mode, except if move is received.
// Sufficient condition because Board already knows which turn it is.
if (!navigate && this.game.mode!="analyze" && !receive
- && this.cursor < this.moves.length-1)
+ && (this.game.score != "*" || this.cursor < this.moves.length-1))
{
return;
}
else
this.moves = this.moves.slice(0,this.cursor).concat([move]);
}
- if (!navigate && this.game.mode!="analyze")
- this.$emit("newmove", move); //post-processing (e.g. computer play)
// Is opponent in check?
this.incheck = this.vr.getCheckSquares(this.vr.turn);
const score = this.vr.getCurrentScore();
else //just show score on screen (allow undo)
this.showEndgameMsg(score + " . " + message);
}
+ if (!navigate && this.game.mode!="analyze")
+ this.$emit("newmove", move); //post-processing (e.g. computer play)
};
if (!!receive && this.game.vname != "Dark")
this.animateMove(move, doPlayMove);
<style lang="sass" scoped>
#baseGame
width: 100%
+ &:focus
+ outline: none
#gameContainer
margin-left: auto
});
}
});
- // TODO: why is this wrong?
+ // TODO: why is this wrong? (Maybe because $route still uninitialized?)
//store.initialize(this.$route.path);
store.initialize(window.location.href.split("#")[1]);
// NOTE: at this point, variants and tr(anslations) might be uninitialized
super.updateVariables(move);
if (move.vanish.length >= 2 && move.vanish[1].p == V.KING)
{
- // We took opponent king !
+ // We took opponent king ! (because if castle vanish[1] is a rook)
this.kingPos[this.turn] = [-1,-1];
}
- // Update moves for both colors:
+ // Update lights for both colors:
this.updateEnlightened();
}
}
}
- // Update moves for both colors:
+ // Update lights for both colors:
this.updateEnlightened();
}
const color = this.turn;
const oppCol = V.GetOppCol(color);
const pawnShift = (color == "w" ? -1 : 1);
- const kp = this.kingPos[color];
// Do not cheat: the current enlightment is all we can see
const myLight = JSON.parse(JSON.stringify(this.enlightened[color]));
// Can a slider on (i,j) apparently take my king?
// NOTE: inaccurate because assume yes if some squares are shadowed
const sliderTake = ([i,j], piece) => {
+ const kp = this.kingPos[color];
let step = undefined;
if (piece == V.BISHOP)
{
// Check for obstacles
let obstacle = false;
for (
- let x=kp[0]+step[0], y=kp[1]+step[1];
- x != i && y != j;
- x += step[0], y+= step[1])
- {
+ let x=kp[0]+step[0], y=kp[1]+step[1];
+ x != i && y != j;
+ x += step[0], y += step[1])
+ {
if (myLight[x][y] && this.board[x][y] != V.EMPTY)
{
obstacle = true;
// Do I see something which can take my king ?
const kingThreats = () => {
+ const kp = this.kingPos[color];
for (let i=0; i<V.size.x; i++)
{
for (let j=0; j<V.size.y; j++)
move.eval = -maxeval;
}
this.undo(move);
- if (!!move.eval)
+
+ if (!!move.eval)
continue;
move.eval = 0; //a priori...
.row
#aboveBoard.col-sm-12.col-md-9.col-md-offset-3.col-lg-10.col-lg-offset-2
button#chatBtn(onClick="doClick('modalChat')") Chat
- #actions(v-if="game.mode!='analyze' && game.score=='*'")
+ #actions(v-if="game.score=='*'")
button(@click="clickDraw" :class="{['draw-' + drawOffer]: true}") Draw
button(@click="abortGame") Abort
button(@click="resign") Resign
document.getElementById("chatBtn").style.backgroundColor = "#c5fefe";
},
gameOver: function(score, scoreMsg) {
- this.game.mode = "analyze";
this.game.score = score;
this.game.scoreMsg = scoreMsg;
const myIdx = this.game.players.findIndex(p => {
.row
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
.collapse
- input#challengeSection(type="radio" checked aria-hidden="true" name="accordion")
- label(for="challengeSection" aria-hidden="true") Challenges
div
.button-group
button(@click="cdisplay='live'") Live Challenges
:challenges="filterChallenges('live')" @click-challenge="clickChallenge")
ChallengeList(v-show="cdisplay=='corr'"
:challenges="filterChallenges('corr')" @click-challenge="clickChallenge")
- input#peopleSection(type="radio" aria-hidden="true" name="accordion")
- label(for="peopleSection" aria-hidden="true") People
div
.button-group
button(@click="pdisplay='players'") Players
| {{ whatPlayerDoes(p) }}
#chat(v-show="pdisplay=='chat'")
Chat(:players="[]")
- input#gameSection(type="radio" aria-hidden="true" name="accordion")
- label(for="gameSection" aria-hidden="true") Games
div
.button-group
button(@click="gdisplay='live'") Live games
| Practice
button(v-show="gameInProgress" @click="() => stopGame()")
| Stop game
- button(v-if="gameInfo.vname!='Dark'" @click="gotoAnalyze")
+ button(v-if="display=='rules' && gameInfo.vname!='Dark'"
+ @click="gotoAnalyze")
| {{ st.tr["Analyze"] }}
.section-content(v-show="display=='rules'" v-html="content")
ComputerGame(v-show="display=='computer'" :game-info="gameInfo"
// user is willing to stop the game:
stopGame: function(score) {
this.gameInfo.score = score || "?";
- this.gameInfo.mode = "analyze";
},
// The game is effectively stopped:
gameStopped: function() {