projects
/
vchess.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8a0f881
)
Avoid direct references to (Dark) variant name in BaseGame, Analyse and Board
author
Benjamin Auder
<benjamin.auder@somewhere>
Wed, 19 Feb 2020 14:15:20 +0000
(15:15 +0100)
committer
Benjamin Auder
<benjamin.auder@somewhere>
Wed, 19 Feb 2020 14:15:20 +0000
(15:15 +0100)
client/src/base_rules.js
patch
|
blob
|
blame
|
history
client/src/components/BaseGame.vue
patch
|
blob
|
blame
|
history
client/src/components/Board.vue
patch
|
blob
|
blame
|
history
client/src/components/ComputerGame.vue
patch
|
blob
|
blame
|
history
client/src/translations/en.js
patch
|
blob
|
blame
|
history
client/src/translations/es.js
patch
|
blob
|
blame
|
history
client/src/translations/fr.js
patch
|
blob
|
blame
|
history
client/src/variants/Dark.js
patch
|
blob
|
blame
|
history
client/src/views/Analyse.vue
patch
|
blob
|
blame
|
history
client/src/views/Rules.vue
patch
|
blob
|
blame
|
history
diff --git
a/client/src/base_rules.js
b/client/src/base_rules.js
index
42d9bdc
..
5ebe499
100644
(file)
--- a/
client/src/base_rules.js
+++ b/
client/src/base_rules.js
@@
-32,13
+32,26
@@
export const ChessRules = class ChessRules {
//////////////
// MISC UTILS
//////////////
// MISC UTILS
+ // Some variants don't have flags:
static get HasFlags() {
return true;
static get HasFlags() {
return true;
- }
//some variants don't have flags
+ }
+ // Some variants don't have en-passant
static get HasEnpassant() {
return true;
static get HasEnpassant() {
return true;
- } //some variants don't have ep.
+ }
+
+ // Some variants cannot have analyse mode
+ static get CanAnalyse() {
+ return true;
+ }
+
+ // Some variants show incomplete information,
+ // and thus show only a partial moves list or no list at all.
+ static get ShowMoves() {
+ return "all";
+ }
// Path to pieces
static getPpath(b) {
// Path to pieces
static getPpath(b) {
diff --git
a/client/src/components/BaseGame.vue
b/client/src/components/BaseGame.vue
index
2f49169
..
07d62cf
100644
(file)
--- a/
client/src/components/BaseGame.vue
+++ b/
client/src/components/BaseGame.vue
@@
-33,14
+33,15
@@
div#baseGame(
Board(
:vr="vr"
:last-move="lastMove"
Board(
:vr="vr"
:last-move="lastMove"
- :analyze="analyze"
+ :analyze="game.mode=='analyze'"
+ :score="game.score"
:user-color="game.mycolor"
:orientation="orientation"
:vname="game.vname"
:incheck="incheck"
@play-move="play"
)
:user-color="game.mycolor"
:orientation="orientation"
:vname="game.vname"
:incheck="incheck"
@play-move="play"
)
- #turnIndicator(v-if="
game.vname=='Dark' && game.score=='*'
") {{ turn }}
+ #turnIndicator(v-if="
showTurn
") {{ turn }}
#controls
button(@click="gotoBegin()") <<
button(@click="undo()") <
#controls
button(@click="gotoBegin()") <<
button(@click="undo()") <
@@
-48,16
+49,16
@@
div#baseGame(
button(@click="play()") >
button(@click="gotoEnd()") >>
#belowControls
button(@click="play()") >
button(@click="gotoEnd()") >>
#belowControls
- #downloadDiv(v-if="
game.vname!='Dark' || game.score!='*'
")
+ #downloadDiv(v-if="
allowDownloadPGN
")
a#download(href="#")
button(@click="download()") {{ st.tr["Download"] }} PGN
button(onClick="window.doClick('modalAdjust')") ⤢
button(
a#download(href="#")
button(@click="download()") {{ st.tr["Download"] }} PGN
button(onClick="window.doClick('modalAdjust')") ⤢
button(
- v-if="
game.vname!='Dark' && game.mode!='analyze'
"
+ v-if="
canAnalyze
"
@click="analyzePosition()"
)
| {{ st.tr["Analyse"] }}
@click="analyzePosition()"
)
| {{ st.tr["Analyse"] }}
- // NOTE:
rather ugly hack to avoid showing twice "rules" link...
+ // NOTE:
variants pages already have a "Rules" link on top
button(
v-if="!$route.path.match('/variants/')"
@click="showRules()"
button(
v-if="!$route.path.match('/variants/')"
@click="showRules()"
@@
-122,17
+123,19
@@
export default {
},
computed: {
showMoves: function() {
},
computed: {
showMoves: function() {
- return this.game.vname != "Dark" || this.game.score != "*";
+ return this.game.score != "*" || (window.V && V.ShowMoves == "all");
+ },
+ showTurn: function() {
+ return this.game.score == '*' && window.V && V.ShowMoves != "all";
},
turn: function() {
return this.st.tr[(this.vr.turn == 'w' ? "White" : "Black") + " to move"];
},
},
turn: function() {
return this.st.tr[(this.vr.turn == 'w' ? "White" : "Black") + " to move"];
},
- analyze: function() {
- return (
- this.game.mode == "analyze" ||
- // From Board viewpoint, a finished Dark game == analyze (TODO: unclear)
- (this.game.vname == "Dark" && this.game.score != "*")
- );
+ canAnalyze: function() {
+ return this.game.mode != "analyze" && window.V && V.CanAnalyze;
+ },
+ allowDownloadPGN: function() {
+ return this.game.score != "*" || (window.V && V.ShowMoves == "all");
}
},
created: function() {
}
},
created: function() {
@@
-381,7
+384,7
@@
export default {
if (!navigate && this.game.mode != "analyze")
this.$emit("newmove", move); //post-processing (e.g. computer play)
};
if (!navigate && this.game.mode != "analyze")
this.$emit("newmove", move); //post-processing (e.g. computer play)
};
- if (!!receive &&
this.game.vname != "Dark
")
+ if (!!receive &&
V.ShowMoves == "all
")
this.animateMove(move, doPlayMove);
else doPlayMove();
},
this.animateMove(move, doPlayMove);
else doPlayMove();
},
diff --git
a/client/src/components/Board.vue
b/client/src/components/Board.vue
index
45c7293
..
bd2612d
100644
(file)
--- a/
client/src/components/Board.vue
+++ b/
client/src/components/Board.vue
@@
-11,6
+11,7
@@
export default {
"vr",
"lastMove",
"analyze",
"vr",
"lastMove",
"analyze",
+ "score",
"incheck",
"orientation",
"userColor",
"incheck",
"orientation",
"userColor",
@@
-46,9
+47,9
@@
export default {
incheckSq[sq[0]][sq[1]] = true;
});
incheckSq[sq[0]][sq[1]] = true;
});
- // Create board element (+ reserves if needed by variant
or mode
)
+ // Create board element (+ reserves if needed by variant)
const lm = this.lastMove;
const lm = this.lastMove;
- const showLight = this.settings.highlight &&
this.vname != "Dark
";
+ const showLight = this.settings.highlight &&
V.ShowMoves == "all
";
const gameDiv = h(
"div",
{
const gameDiv = h(
"div",
{
@@
-72,8
+73,7
@@
export default {
let elems = [];
if (
this.vr.board[ci][cj] != V.EMPTY &&
let elems = [];
if (
this.vr.board[ci][cj] != V.EMPTY &&
- (this.vname != "Dark" ||
- this.analyze ||
+ (!this.vr.enlightened || this.analyze || this.score != "*" ||
(!!this.userColor &&
this.vr.enlightened[this.userColor][ci][cj]))
) {
(!!this.userColor &&
this.vr.enlightened[this.userColor][ci][cj]))
) {
@@
-116,8
+116,9
@@
export default {
"dark-square": (i + j) % 2 == 1,
[this.settings.bcolor]: true,
"in-shadow":
"dark-square": (i + j) % 2 == 1,
[this.settings.bcolor]: true,
"in-shadow":
- this.vname == "Dark" &&
!this.analyze &&
!this.analyze &&
+ this.score == "*" &&
+ this.vr.enlightened &&
(!this.userColor ||
!this.vr.enlightened[this.userColor][ci][cj]),
highlight:
(!this.userColor ||
!this.vr.enlightened[this.userColor][ci][cj]),
highlight:
diff --git
a/client/src/components/ComputerGame.vue
b/client/src/components/ComputerGame.vue
index
4d35471
..
0d566a8
100644
(file)
--- a/
client/src/components/ComputerGame.vue
+++ b/
client/src/components/ComputerGame.vue
@@
-57,8
+57,8
@@
export default {
const delay = Math.max(500 - (Date.now() - this.timeStart), 0);
setTimeout(() => {
if (this.currentUrl != document.location.href) return; //page change
const delay = Math.max(500 - (Date.now() - this.timeStart), 0);
setTimeout(() => {
if (this.currentUrl != document.location.href) return; //page change
- // NOTE:
Dark and 2-moves are incompatible
- const animate =
this.gameInfo.vname != "Dark
";
+ // NOTE:
do not animate move if special display (ShowMoves != "all")
+ const animate =
V.ShowMoves == "all
";
const animDelay = animate ? 250 : 0;
let moveIdx = 0;
let self = this;
const animDelay = animate ? 250 : 0;
let moveIdx = 0;
let self = this;
diff --git
a/client/src/translations/en.js
b/client/src/translations/en.js
index
94be8f8
..
5afbc59
100644
(file)
--- a/
client/src/translations/en.js
+++ b/
client/src/translations/en.js
@@
-4,8
+4,6
@@
export const translations = {
"Accept draw?": "Accept draw?",
All: "All",
Analyse: "Analyse",
"Accept draw?": "Accept draw?",
All: "All",
Analyse: "Analyse",
- "Analyse in Dark mode makes no sense!":
- "Analyse in Dark mode makes no sense!",
"Any player": "Any player",
"Are you sure?": "Are you sure?",
"Authentication successful!": "Authentication successful!",
"Any player": "Any player",
"Are you sure?": "Are you sure?",
"Authentication successful!": "Authentication successful!",
diff --git
a/client/src/translations/es.js
b/client/src/translations/es.js
index
56c6733
..
fd9f28e
100644
(file)
--- a/
client/src/translations/es.js
+++ b/
client/src/translations/es.js
@@
-4,8
+4,6
@@
export const translations = {
"Accept draw?": "¿Acceptar tablas?",
All: "Todos",
Analyse: "Analizar",
"Accept draw?": "¿Acceptar tablas?",
All: "Todos",
Analyse: "Analizar",
- "Analyse in Dark mode makes no sense!":
- "¡Analizar en modo Dark no tiene sentido!",
"Any player": "Cualquier jugador",
Apply: "Aplicar",
"Are you sure?": "¿Está usted seguro?",
"Any player": "Cualquier jugador",
Apply: "Aplicar",
"Are you sure?": "¿Está usted seguro?",
diff --git
a/client/src/translations/fr.js
b/client/src/translations/fr.js
index
3e9aa6a
..
0d776b4
100644
(file)
--- a/
client/src/translations/fr.js
+++ b/
client/src/translations/fr.js
@@
-4,8
+4,6
@@
export const translations = {
"Accept draw?": "Accepter la nulle ?",
All: "Tous",
Analyse: "Analyser",
"Accept draw?": "Accepter la nulle ?",
All: "Tous",
Analyse: "Analyser",
- "Analyse in Dark mode makes no sense!":
- "Analyser en mode Dark n'a pas de sens !",
"Any player": "N'importe qui",
Apply: "Appliquer",
"Authentication successful!": "Authentification réussie !",
"Any player": "N'importe qui",
Apply: "Appliquer",
"Authentication successful!": "Authentification réussie !",
diff --git
a/client/src/variants/Dark.js
b/client/src/variants/Dark.js
index
358362c
..
cdacf9d
100644
(file)
--- a/
client/src/variants/Dark.js
+++ b/
client/src/variants/Dark.js
@@
-3,7
+3,16
@@
import { ArrayFun } from "@/utils/array";
import { randInt } from "@/utils/alea";
export const VariantRules = class DarkRules extends ChessRules {
import { randInt } from "@/utils/alea";
export const VariantRules = class DarkRules extends ChessRules {
- // Standard rules, in the shadow
+ // Analyse in Dark mode makes no sense
+ static get CanAnalyse() {
+ return false;
+ }
+
+ // Moves are revealed only when game ends
+ static get ShowMoves() {
+ return "none";
+ }
+
setOtherVariables(fen) {
super.setOtherVariables(fen);
const [sizeX, sizeY] = [V.size.x, V.size.y];
setOtherVariables(fen) {
super.setOtherVariables(fen);
const [sizeX, sizeY] = [V.size.x, V.size.y];
diff --git
a/client/src/views/Analyse.vue
b/client/src/views/Analyse.vue
index
7259632
..
d1c6d59
100644
(file)
--- a/
client/src/views/Analyse.vue
+++ b/
client/src/views/Analyse.vue
@@
-37,7
+37,6
@@
export default {
},
vr: null, //"variant rules" object initialized from FEN
curFen: ""
},
vr: null, //"variant rules" object initialized from FEN
curFen: ""
- //people: [], //players + observers //TODO later: interactive analyze...
};
},
watch: {
};
},
watch: {
@@
-50,13
+49,8
@@
export default {
},
created: function() {
this.gameRef.vname = this.$route.params["vname"];
},
created: function() {
this.gameRef.vname = this.$route.params["vname"];
- if (this.gameRef.vname == "Dark") {
- alert(this.st.tr["Analyse in Dark mode makes no sense!"]);
- history.back(); //or this.$router.go(-1)
- } else {
- this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
- this.initialize();
- }
+ this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
+ this.initialize();
},
methods: {
initialize: async function() {
},
methods: {
initialize: async function() {
diff --git
a/client/src/views/Rules.vue
b/client/src/views/Rules.vue
index
55564ff
..
8ac03a9
100644
(file)
--- a/
client/src/views/Rules.vue
+++ b/
client/src/views/Rules.vue
@@
-20,7
+20,7
@@
main
)
| {{ st.tr["Stop game"] }}
button(
)
| {{ st.tr["Stop game"] }}
button(
- v-if="
display=='rules' && gameInfo.vname!='Dark'
"
+ v-if="
showAnalyzeBtn
"
@click="gotoAnalyze()"
)
| {{ st.tr["Analyse"] }}
@click="gotoAnalyze()"
)
| {{ st.tr["Analyse"] }}
@@
-69,6
+69,9
@@
export default {
this.re_setVariant(this.$route.params["vname"]);
},
computed: {
this.re_setVariant(this.$route.params["vname"]);
},
computed: {
+ showAnalyzeBtn: function() {
+ return (this.display=='rules' && (!window.V || V.CanAnalyse));
+ },
content: function() {
if (!this.gameInfo.vname) return ""; //variant not set yet
// (AJAX) Request to get rules content (plain text, HTML)
content: function() {
if (!this.gameInfo.vname) return ""; //variant not set yet
// (AJAX) Request to get rules content (plain text, HTML)