projects
/
vchess.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
0e16cb2
)
'update'
author
Benjamin Auder
<benjamin.auder@somewhere>
Mon, 3 Feb 2020 08:13:56 +0000
(09:13 +0100)
committer
Benjamin Auder
<benjamin.auder@somewhere>
Mon, 3 Feb 2020 08:13:56 +0000
(09:13 +0100)
client/src/components/BaseGame.vue
patch
|
blob
|
blame
|
history
client/src/main.js
patch
|
blob
|
blame
|
history
client/src/variants/Dark.js
patch
|
blob
|
blame
|
history
client/src/views/Game.vue
patch
|
blob
|
blame
|
history
client/src/views/Hall.vue
patch
|
blob
|
blame
|
history
client/src/views/Rules.vue
patch
|
blob
|
blame
|
history
diff --git
a/client/src/components/BaseGame.vue
b/client/src/components/BaseGame.vue
index
dd8c5c8
..
07343c5
100644
(file)
--- a/
client/src/components/BaseGame.vue
+++ b/
client/src/components/BaseGame.vue
@@
-8,10
+8,10
@@
div#baseGame(tabindex=-1 @click="() => focusBg()"
h3#eogMessage.section {{ endgameMessage }}
#gameContainer
#boardContainer
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")
: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") <<
| {{ turn }}
#controls
button(@click="gotoBegin") <<
@@
-20,12
+20,15
@@
div#baseGame(tabindex=-1 @click="() => focusBg()"
button(@click="() => play()") >
button(@click="gotoEnd") >>
#pgnDiv
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(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"
#movesList
MoveList(v-if="showMoves" :score="game.score" :message="game.scoreMsg"
:firstNum="firstMoveNumber" :moves="moves" :cursor="cursor"
@@
-74,7
+77,7
@@
export default {
},
computed: {
showMoves: function() {
},
computed: {
showMoves: function() {
- return this.game.vname != "Dark" || this.game.
mode=="analyze
";
+ return this.game.vname != "Dark" || this.game.
score != "*
";
},
turn: function() {
let color = "";
},
turn: function() {
let color = "";
@@
-85,6
+88,11
@@
export default {
color = "Black";
return color + " turn";
},
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)
},
created: function() {
if (!!this.game.fenStart)
@@
-132,7
+140,8
@@
export default {
}
},
handleScroll: function(e) {
}
},
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)
{
e.preventDefault();
if (e.deltaY < 0)
@@
-272,7
+281,7
@@
export default {
// 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
// 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;
}
{
return;
}
@@
-304,8
+313,6
@@
export default {
else
this.moves = this.moves.slice(0,this.cursor).concat([move]);
}
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();
// Is opponent in check?
this.incheck = this.vr.getCheckSquares(this.vr.turn);
const score = this.vr.getCurrentScore();
@@
-317,6
+324,8
@@
export default {
else //just show score on screen (allow undo)
this.showEndgameMsg(score + " . " + message);
}
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);
};
if (!!receive && this.game.vname != "Dark")
this.animateMove(move, doPlayMove);
@@
-375,6
+384,8
@@
export default {
<style lang="sass" scoped>
#baseGame
width: 100%
<style lang="sass" scoped>
#baseGame
width: 100%
+ &:focus
+ outline: none
#gameContainer
margin-left: auto
#gameContainer
margin-left: auto
diff --git
a/client/src/main.js
b/client/src/main.js
index
6e22936
..
7015362
100644
(file)
--- a/
client/src/main.js
+++ b/
client/src/main.js
@@
-22,7
+22,7
@@
new Vue({
});
}
});
});
}
});
- // 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
//store.initialize(this.$route.path);
store.initialize(window.location.href.split("#")[1]);
// NOTE: at this point, variants and tr(anslations) might be uninitialized
diff --git
a/client/src/variants/Dark.js
b/client/src/variants/Dark.js
index
777aacc
..
bc14cfa
100644
(file)
--- a/
client/src/variants/Dark.js
+++ b/
client/src/variants/Dark.js
@@
-104,11
+104,11
@@
export const VariantRules = class DarkRules extends ChessRules
super.updateVariables(move);
if (move.vanish.length >= 2 && move.vanish[1].p == V.KING)
{
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];
}
this.kingPos[this.turn] = [-1,-1];
}
- // Update
move
s for both colors:
+ // Update
light
s for both colors:
this.updateEnlightened();
}
this.updateEnlightened();
}
@@
-130,7
+130,7
@@
export const VariantRules = class DarkRules extends ChessRules
}
}
}
}
- // Update
move
s for both colors:
+ // Update
light
s for both colors:
this.updateEnlightened();
}
this.updateEnlightened();
}
@@
-157,7
+157,6
@@
export const VariantRules = class DarkRules extends ChessRules
const color = this.turn;
const oppCol = V.GetOppCol(color);
const pawnShift = (color == "w" ? -1 : 1);
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]));
// Do not cheat: the current enlightment is all we can see
const myLight = JSON.parse(JSON.stringify(this.enlightened[color]));
@@
-165,6
+164,7
@@
export const VariantRules = class DarkRules extends ChessRules
// 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) => {
// 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)
{
let step = undefined;
if (piece == V.BISHOP)
{
@@
-189,10
+189,10
@@
export const VariantRules = class DarkRules extends ChessRules
// Check for obstacles
let obstacle = false;
for (
// 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;
if (myLight[x][y] && this.board[x][y] != V.EMPTY)
{
obstacle = true;
@@
-206,6
+206,7
@@
export const VariantRules = class DarkRules extends ChessRules
// Do I see something which can take my king ?
const kingThreats = () => {
// 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++)
for (let i=0; i<V.size.x; i++)
{
for (let j=0; j<V.size.y; j++)
@@
-259,7
+260,8
@@
export const VariantRules = class DarkRules extends ChessRules
move.eval = -maxeval;
}
this.undo(move);
move.eval = -maxeval;
}
this.undo(move);
- if (!!move.eval)
+
+ if (!!move.eval)
continue;
move.eval = 0; //a priori...
continue;
move.eval = 0; //a priori...
diff --git
a/client/src/views/Game.vue
b/client/src/views/Game.vue
index
8f9b946
..
c0c5031
100644
(file)
--- a/
client/src/views/Game.vue
+++ b/
client/src/views/Game.vue
@@
-10,7
+10,7
@@
main
.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
.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
button(@click="clickDraw" :class="{['draw-' + drawOffer]: true}") Draw
button(@click="abortGame") Abort
button(@click="resign") Resign
@@
-560,7
+560,6
@@
export default {
document.getElementById("chatBtn").style.backgroundColor = "#c5fefe";
},
gameOver: function(score, scoreMsg) {
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 => {
this.game.score = score;
this.game.scoreMsg = scoreMsg;
const myIdx = this.game.players.findIndex(p => {
diff --git
a/client/src/views/Hall.vue
b/client/src/views/Hall.vue
index
2df03e6
..
0bc037a
100644
(file)
--- a/
client/src/views/Hall.vue
+++ b/
client/src/views/Hall.vue
@@
-32,8
+32,6
@@
main
.row
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
.collapse
.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
div
.button-group
button(@click="cdisplay='live'") Live Challenges
@@
-42,8
+40,6
@@
main
:challenges="filterChallenges('live')" @click-challenge="clickChallenge")
ChallengeList(v-show="cdisplay=='corr'"
:challenges="filterChallenges('corr')" @click-challenge="clickChallenge")
: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
div
.button-group
button(@click="pdisplay='players'") Players
@@
-57,8
+53,6
@@
main
| {{ whatPlayerDoes(p) }}
#chat(v-show="pdisplay=='chat'")
Chat(: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
div
.button-group
button(@click="gdisplay='live'") Live games
diff --git
a/client/src/views/Rules.vue
b/client/src/views/Rules.vue
index
2541661
..
a3331d7
100644
(file)
--- a/
client/src/views/Rules.vue
+++ b/
client/src/views/Rules.vue
@@
-10,7
+10,8
@@
main
| Practice
button(v-show="gameInProgress" @click="() => stopGame()")
| Stop game
| 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"
| {{ st.tr["Analyze"] }}
.section-content(v-show="display=='rules'" v-html="content")
ComputerGame(v-show="display=='computer'" :game-info="gameInfo"
@@
-98,7
+99,6
@@
export default {
// user is willing to stop the game:
stopGame: function(score) {
this.gameInfo.score = score || "?";
// 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() {
},
// The game is effectively stopped:
gameStopped: function() {