//////////////
// MISC UTILS
+ // Some variants don't have flags:
static get HasFlags() {
return true;
- } //some variants don't have flags
+ }
+ // Some variants don't have en-passant
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) {
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"
)
- #turnIndicator(v-if="game.vname=='Dark' && game.score=='*'") {{ turn }}
+ #turnIndicator(v-if="showTurn") {{ turn }}
#controls
button(@click="gotoBegin()") <<
button(@click="undo()") <
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(
- v-if="game.vname!='Dark' && game.mode!='analyze'"
+ v-if="canAnalyze"
@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()"
},
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"];
},
- 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() {
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();
},
"vr",
"lastMove",
"analyze",
+ "score",
"incheck",
"orientation",
"userColor",
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 showLight = this.settings.highlight && this.vname != "Dark";
+ const showLight = this.settings.highlight && V.ShowMoves == "all";
const gameDiv = h(
"div",
{
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]))
) {
"dark-square": (i + j) % 2 == 1,
[this.settings.bcolor]: true,
"in-shadow":
- this.vname == "Dark" &&
!this.analyze &&
+ this.score == "*" &&
+ this.vr.enlightened &&
(!this.userColor ||
!this.vr.enlightened[this.userColor][ci][cj]),
highlight:
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;
"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!",
"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?",
"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 !",
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];
},
vr: null, //"variant rules" object initialized from FEN
curFen: ""
- //people: [], //players + observers //TODO later: interactive analyze...
};
},
watch: {
},
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() {
)
| {{ st.tr["Stop game"] }}
button(
- v-if="display=='rules' && gameInfo.vname!='Dark'"
+ v-if="showAnalyzeBtn"
@click="gotoAnalyze()"
)
| {{ st.tr["Analyse"] }}
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)