A few fixes + prepare translations + rules for last 4 variants
authorBenjamin Auder <benjamin.auder@somewhere>
Wed, 26 Dec 2018 01:11:20 +0000 (02:11 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Wed, 26 Dec 2018 01:11:20 +0000 (02:11 +0100)
public/javascripts/base_rules.js
public/javascripts/components/game.js
views/rules/Berolina/en.pug [new file with mode: 0644]
views/rules/Dark/en.pug [new file with mode: 0644]
views/rules/Marseille/en.pug [new file with mode: 0644]
views/rules/Upsidedown/en.pug [new file with mode: 0644]
views/translations/en.pug
views/translations/es.pug
views/translations/fr.pug

index ba77d71..389ba34 100644 (file)
@@ -975,8 +975,20 @@ class ChessRules
        // After move is played, update variables + flags
        updateVariables(move)
        {
-               const piece = move.vanish[0].p;
-               let c = move.vanish[0].c;
+               let piece = undefined;
+               let c = undefined;
+               if (move.vanish.length >= 1)
+               {
+                       // Usual case, something is moved
+                       piece = move.vanish[0].p;
+                       c = move.vanish[0].c;
+               }
+               else
+               {
+                       // Crazyhouse-like variants
+                       piece = move.appear[0].p;
+                       c = move.appear[0].c;
+               }
                if (c == "c") //if (!["w","b"].includes(c))
                {
                        // 'c = move.vanish[0].c' doesn't work for Checkered
index d8f06b3..94340e6 100644 (file)
@@ -1105,7 +1105,7 @@ Vue.component('my-game', {
                this.conn.onclose = socketCloseListener;
                // Listen to keyboard left/right to navigate in game
                document.onkeydown = event => {
-                       if (["idle","chat"].includes(this.mode) &&
+                       if (["human","computer"].includes(this.mode) &&
                                !!this.vr && this.vr.moves.length > 0 && [37,39].includes(event.keyCode))
                        {
                                event.preventDefault();
@@ -1307,7 +1307,7 @@ Vue.component('my-game', {
                        this.endGame(this.mycolor=="w"?"0-1":"1-0");
                },
                newGame: function(mode, fenInit, color, oppId) {
-                       const fen = "rnbbqkrn/1ppppp1p/p5p1/8/8/3P4/PPP1PPPP/BNQBRKRN w1 1111 -"; //fenInit || VariantRules.GenRandInitFen();
+                       const fen = fenInit || VariantRules.GenRandInitFen();
                        console.log(fen); //DEBUG
                        if (mode=="human" && !oppId)
                        {
@@ -1388,7 +1388,7 @@ Vue.component('my-game', {
                        else if (mode == "computer")
                        {
                                this.compWorker.postMessage(["init",this.vr.getFen()]);
-                               this.mycolor = "w";//(Math.random() < 0.5 ? 'w' : 'b');
+                               this.mycolor = (Math.random() < 0.5 ? 'w' : 'b');
                                if (this.mycolor != this.vr.turn)
                                        this.playComputerMove();
                        }
@@ -1598,24 +1598,24 @@ Vue.component('my-game', {
                                        // Send the move to web worker (TODO: including his own moves?!)
                                        this.compWorker.postMessage(["newmove",move]);
                                }
+                               const eog = this.vr.checkGameOver();
+                               if (eog != "*")
+                               {
+                                       if (["human","computer"].includes(this.mode))
+                                               this.endGame(eog);
+                                       else
+                                       {
+                                               // Just show score on screen (allow undo)
+                                               this.score = eog;
+                                               this.showScoreMsg();
+                                       }
+                               }
                        }
                        else
                        {
                                VariantRules.PlayOnBoard(this.vr.board, move);
                                this.$forceUpdate(); //TODO: ?!
                        }
-                       const eog = this.vr.checkGameOver();
-                       if (eog != "*")
-                       {
-                               if (["human","computer"].includes(this.mode))
-                                       this.endGame(eog);
-                               else
-                               {
-                                       // Just show score on screen (allow undo)
-                                       this.score = eog;
-                                       this.showScoreMsg();
-                               }
-                       }
                        if (["human","computer","friend"].includes(this.mode))
                                this.updateStorage(); //after our moves and opponent moves
                        if (this.mode == "computer" && this.vr.turn != this.mycolor && this.score == "*")
diff --git a/views/rules/Berolina/en.pug b/views/rules/Berolina/en.pug
new file mode 100644 (file)
index 0000000..60080ea
--- /dev/null
@@ -0,0 +1,28 @@
+p.boxed
+       | Pawns advance diagonally and capture by moving forward.
+
+h3 Specifications
+
+ul
+       li Chessboard: standard.
+       li Material: standard.
+       li Non-capturing moves: different pawn moves.
+       li Special moves: standard (different en-passant).
+       li Captures: standard (except pawns).
+       li End of game: standard.
+
+h3 Basics
+
+p.
+       TODO: explain...
+
+figure.diagram-container
+       .diagram
+               | fen:r3kbnr/pp3ppp/3p4/4p3/8/8/PPPPPPPP/R1BQKBNR:
+       figcaption After the moves 1.Nc3 d6?? 2.Nd5 e5 3.Nxc7
+
+h3 More information
+
+p.
+       Possible starting point Wikipedia page ?
+
diff --git a/views/rules/Dark/en.pug b/views/rules/Dark/en.pug
new file mode 100644 (file)
index 0000000..49a4fc8
--- /dev/null
@@ -0,0 +1,33 @@
+p.boxed
+       | You only see what your pieces can reach. Incomplete information game.
+
+h3 Specifications
+
+ul
+       li Chessboard: standard.
+       li Material: standard.
+       li Non-capturing moves: standard.
+       li Special moves: standard.
+       li Captures: standard.
+       li End of game: capture the king.
+
+p Incomplete information version of the orthodox game (also shuffled).
+
+h3 Basics
+
+p.
+       TODO
+
+figure.diagram-container
+       .diagram
+               | fen:r3kbnr/pp3ppp/3p4/4p3/8/8/PPPPPPPP/R1BQKBNR:
+       figcaption After the moves 1.Nc3 d6?? 2.Nd5 e5 3.Nxc7
+
+h3 End of the game
+
+p Win by capturing the king (no checks, no stalemate).
+
+h3 More information
+
+p.
+       TODO: quote buho21, ...
diff --git a/views/rules/Marseille/en.pug b/views/rules/Marseille/en.pug
new file mode 100644 (file)
index 0000000..221bd83
--- /dev/null
@@ -0,0 +1,35 @@
+p.boxed
+       | Move twice at every turn.
+
+h3 Specifications
+
+ul
+       li Chessboard: standard.
+       li Material: standard.
+       li Non-capturing moves: standard.
+       li Special moves: standard.
+       li Captures: standard.
+       li End of game: standard.
+
+p.
+       The only difference with orthodox chess is the double-move rule,
+       but this affects the game a lot.
+
+h3 Basics
+
+p.
+       TODO: explain, every turn twice except if check on 1st turn, or
+       very first move in game.
+       En-passant: possible in any order if 2 ep squares,
+       otherwise has to be the first move.
+       OK even if opponent moved his pawn at subturn 1.
+
+figure.diagram-container
+       .diagram
+               | fen:r3kbnr/pp3ppp/3p4/4p3/8/8/PPPPPPPP/R1BQKBNR:
+       figcaption After the moves 1.Nc3 d6?? 2.Nd5 e5 3.Nxc7
+
+h3 More information
+
+p.
+       Possible starting point Wikipedia page ?
diff --git a/views/rules/Upsidedown/en.pug b/views/rules/Upsidedown/en.pug
new file mode 100644 (file)
index 0000000..695cbe4
--- /dev/null
@@ -0,0 +1,46 @@
+p.boxed
+       | Pawns start on the 7th rank. Move a knight to promote them.
+
+Diagram: ... threatens Nc5-Nd3# and allow 2.b8=Q
+
+figure.diagram-container
+       .diagram
+               | fen::
+       figcaption Standard initial position after 1.Na6
+
+h3 Specifications
+
+ul
+       li Chessboard: standard.
+       li Material: standard.
+       li Non-capturing moves: standard.
+       li Special moves: no castling (and no en-passant).
+       li Captures: standard.
+       li End of game: standard.
+
+p.
+       ...(Almost) Only the initial position changes, but this is a very big change.
+       In particular, castling would be rather pointless so it's disabled here.
+       En-passant captures are impossible because all pawns already reached 7th rank.
+
+h3 Note on initial position
+
+p.
+       Since truly random start can allow un-defendable mate in 3 with a knight,
+       the kings touch at least one knight in the initial position.
+       This allows to move free out of potential check from the very beginning.
+       Here is an example:
+
+// TODO: diagram
+figure.diagram-container
+       .diagram
+               | fen:r7/2n5/1q6/5k2/8/8/K7/8:
+       figcaption.
+               The king cannot take on a8 because it's guarded by the knight: it's checkmate
+
+h3 Source
+
+p
+       | See for example the 
+       a(href="https://www.chessvariants.com/diffsetup.dir/upside.html") Upside down chess
+       | &nbsp;page on chessvariants.com.
index a05b1fa..f07764b 100644 (file)
                "Exotic captures": "Exotic captures",
                "Balanced sliders & leapers": "Balanced sliders & leapers",
                "Reverse captures": "Reverse captures",
+               "Pawns move diagonally": "Pawns move diagonally",
+               "In the shadow": "In the shadow",
+               "Move twice": "Move twice",
+               "Head upside down": "Head upside down",
 
                // Variant page:
                "New game": "New game",
index 6c2dbcf..b589fb1 100644 (file)
                "Exotic captures": "Capturas exóticas",
                "Balanced sliders & leapers": "Modos de desplazamiento equilibrados",
                "Reverse captures": "Capturas invertidas",
+               "Pawns move diagonally": "Peones se mueven en diagonal",
+               "In the shadow": "En la sombra",
+               "Move twice": "Mover dos veces",
+               "Head upside down": "Cabeza al revés",
 
                // Variant page:
                "New game": "Nueva partida",
index e4197b4..8a86df3 100644 (file)
                "Exotic captures": "Captures exotiques",
                "Balanced sliders & leapers": "Modes de déplacement équilibrés",
                "Reverse captures": "Captures inversées",
+               "Pawns move diagonally": "Les pions vont en diagonale",
+               "In the shadow": "Dans l'ombre",
+               "Move twice": "Jouer deux coups",
+               "Head upside down": "La tête à l'envers",
 
                // Variant page:
                "New game": "Nouvelle partie",