From: Benjamin Auder Date: Wed, 19 Dec 2018 20:18:16 +0000 (+0100) Subject: Fix some typos and forgotten things X-Git-Url: https://git.auder.net/variants/Checkered/vendor/css/rpsls.css?a=commitdiff_plain;h=fb6ceeff17b53ab049e14d2bee7a61de92ca4762;p=vchess.git Fix some typos and forgotten things --- diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index e229cdfb..a17876da 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -1316,7 +1316,8 @@ Vue.component('my-game', { const storageVariant = localStorage.getItem("comp-variant"); if (!!storageVariant) { - if (storageVariant !== variant) + const score = localStorage.getItem("comp-score"); + if (storageVariant !== variant && score == "*") { if (!confirm("Unfinished " + storageVariant + " computer game will be erased")) @@ -1324,12 +1325,8 @@ Vue.component('my-game', { return; } } - else - { - const score = localStorage.getItem("comp-score"); - if (score == "*") - return this.continueGame("computer"); - } + else if (score == "*") + return this.continueGame("computer"); } } this.vr = new VariantRules(fen, []); diff --git a/public/javascripts/variants/Antiking.js b/public/javascripts/variants/Antiking.js index 0d342713..e4d402ce 100644 --- a/public/javascripts/variants/Antiking.js +++ b/public/javascripts/variants/Antiking.js @@ -201,7 +201,7 @@ class AntikingRules extends ChessRules return pieces["b"].join("") + "/" + ranks23_black + "/8/8/" + ranks23_white + "/" + pieces["w"].join("").toUpperCase() + - " w 1111"; + " w 1111 -"; } } diff --git a/public/javascripts/variants/Crazyhouse.js b/public/javascripts/variants/Crazyhouse.js index afebcc35..1fff1e91 100644 --- a/public/javascripts/variants/Crazyhouse.js +++ b/public/javascripts/variants/Crazyhouse.js @@ -24,10 +24,21 @@ class CrazyhouseRules extends ChessRules return true; } + static ParseFen(fen) + { + const fenParts = fen.split(" "); + return Object.assign( + ChessRules.ParseFen(fen), + { + reserve: fenParts[4], + promoted: fenParts[5], + } + ); + } + static GenRandInitFen() { - const fen = ChessRules.GenRandInitFen(); - return fen.replace(" w 1111", " w 1111 0000000000 -"); + return ChessRules.GenRandInitFen() + " 0000000000 -"; } getFen() @@ -59,6 +70,8 @@ class CrazyhouseRules extends ChessRules } if (res.length > 0) res = res.slice(0,-1); //remove last comma + else + res = "-"; return res; } @@ -87,10 +100,13 @@ class CrazyhouseRules extends ChessRules } }; this.promoted = doubleArray(V.size.x, V.size.y, false); - for (let square of fenParsd.promoted.split(",")) + if (fenParsed.promoted != "-") { - const [x,y] = V.SquareToCoords(square); - promoted[x][y] = true; + for (let square of fenParsed.promoted.split(",")) + { + const [x,y] = V.SquareToCoords(square); + promoted[x][y] = true; + } } } diff --git a/public/javascripts/variants/Grand.js b/public/javascripts/variants/Grand.js index ec2afd81..22b24948 100644 --- a/public/javascripts/variants/Grand.js +++ b/public/javascripts/variants/Grand.js @@ -18,10 +18,18 @@ class GrandRules extends ChessRules return true; } + static ParseFen(fen) + { + const fenParts = fen.split(" "); + return Object.assign( + ChessRules.ParseFen(fen), + { captured: fenParts[4] } + ); + } + static GenRandInitFen() { - const fen = ChessRules.GenRandInitFen(); - return fen.replace(" w 1111", " w 1111 0000000000"); + return ChessRules.GenRandInitFen() + " 0000000000"; } getFen() diff --git a/public/javascripts/variants/Magnetic.js b/public/javascripts/variants/Magnetic.js index 17efeaa9..6682b270 100644 --- a/public/javascripts/variants/Magnetic.js +++ b/public/javascripts/variants/Magnetic.js @@ -1,6 +1,6 @@ class MagneticRules extends ChessRules { - static get HasEnpassant { return false; } + static get HasEnpassant() { return false; } setOtherVariables(fen) { diff --git a/public/javascripts/variants/Zen.js b/public/javascripts/variants/Zen.js index b090a292..66cd61f4 100644 --- a/public/javascripts/variants/Zen.js +++ b/public/javascripts/variants/Zen.js @@ -1,7 +1,7 @@ class ZenRules extends ChessRules { // NOTE: enPassant, if enabled, would need to redefine carefully getEpSquare - static get HasEnpassant { return false; } + static get HasEnpassant() { return false; } // TODO(?): some duplicated code in 2 next functions getSlideNJumpMoves([x,y], steps, oneStep)