projects
/
vchess.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f6cc7fa
)
Alice almost fixed
author
Benjamin Auder
<benjamin.auder@somewhere>
Fri, 23 Nov 2018 13:20:31 +0000
(14:20 +0100)
committer
Benjamin Auder
<benjamin.auder@somewhere>
Fri, 23 Nov 2018 13:20:31 +0000
(14:20 +0100)
public/javascripts/base_rules.js
patch
|
blob
|
blame
|
history
public/javascripts/components/game.js
patch
|
blob
|
blame
|
history
public/javascripts/variants/Alice.js
patch
|
blob
|
blame
|
history
diff --git
a/public/javascripts/base_rules.js
b/public/javascripts/base_rules.js
index
cb426f3
..
346eff0
100644
(file)
--- a/
public/javascripts/base_rules.js
+++ b/
public/javascripts/base_rules.js
@@
-699,8
+699,6
@@
class ChessRules
play(move, ingame)
{
play(move, ingame)
{
- console.log("play " + this.getNotation(move));
- console.log(JSON.stringify(move));
if (!!ingame)
move.notation = this.getNotation(move);
if (!!ingame)
move.notation = this.getNotation(move);
@@
-718,7
+716,6
@@
class ChessRules
this.moves.pop();
this.unupdateVariables(move);
this.parseFlags(JSON.parse(move.flags));
this.moves.pop();
this.unupdateVariables(move);
this.parseFlags(JSON.parse(move.flags));
- console.log("undo " + this.getNotation(move));
}
//////////////
}
//////////////
diff --git
a/public/javascripts/components/game.js
b/public/javascripts/components/game.js
index
ca8a6bf
..
397ba52
100644
(file)
--- a/
public/javascripts/components/game.js
+++ b/
public/javascripts/components/game.js
@@
-574,7
+574,7
@@
Vue.component('my-game', {
this.newGame("computer");
},
newGame: function(mode, fenInit, color, oppId, moves, continuation) {
this.newGame("computer");
},
newGame: function(mode, fenInit, color, oppId, moves, continuation) {
- const fen =
"pppppppp/rnbqkbnr/8/8/8/8/PPPPPPPP/ROBQKBOR 1111"; //
fenInit || VariantRules.GenRandInitFen();
+ const fen = fenInit || VariantRules.GenRandInitFen();
console.log(fen); //DEBUG
this.score = "*";
if (mode=="human" && !oppId)
console.log(fen); //DEBUG
this.score = "*";
if (mode=="human" && !oppId)
@@
-672,7
+672,7
@@
Vue.component('my-game', {
this.selectedPiece.style.display = "inline-block";
this.selectedPiece.style.zIndex = 3000;
let startSquare = this.getSquareFromId(e.target.parentNode.id);
this.selectedPiece.style.display = "inline-block";
this.selectedPiece.style.zIndex = 3000;
let startSquare = this.getSquareFromId(e.target.parentNode.id);
- this.possibleMoves = t
rue//t
his.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
+ this.possibleMoves = this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
? this.vr.getPossibleMovesFrom(startSquare)
: [];
e.target.parentNode.appendChild(this.selectedPiece);
? this.vr.getPossibleMovesFrom(startSquare)
: [];
e.target.parentNode.appendChild(this.selectedPiece);
diff --git
a/public/javascripts/variants/Alice.js
b/public/javascripts/variants/Alice.js
index
1e1ce46
..
4d10506
100644
(file)
--- a/
public/javascripts/variants/Alice.js
+++ b/
public/javascripts/variants/Alice.js
@@
-50,10
+50,8
@@
class AliceRules extends ChessRules
return sideBoard;
}
return sideBoard;
}
- // TODO: castle & enPassant https://www.chessvariants.com/other.dir/alice.html
- // TODO: enPassant seulement si l'on est du même coté que le coté de départ du pion adverse
- // (en passant en sortant du monde... : il faut donc ajouter des coups non trouvés)
- // castle: check that all destination squares are not occupied
+ // NOTE: castle & enPassant https://www.chessvariants.com/other.dir/alice.html
+ // --> Should be OK as is.
getPotentialMovesFrom([x,y])
{
let sideBoard = this.getBoardOfPiece([x,y]);
getPotentialMovesFrom([x,y])
{
let sideBoard = this.getBoardOfPiece([x,y]);
@@
-67,8
+65,20
@@
class AliceRules extends ChessRules
// Finally filter impossible moves
const mirrorSide = (Object.keys(VariantRules.ALICE_CODES).includes(this.getPiece(x,y)) ? 1 : 2);
return moves.filter(m => {
// Finally filter impossible moves
const mirrorSide = (Object.keys(VariantRules.ALICE_CODES).includes(this.getPiece(x,y)) ? 1 : 2);
return moves.filter(m => {
- if (
this.board[m.end.x][m.end.y] != VariantRules.EMPTY)
+ if (
m.appear.length == 2) //castle
{
{
+ // If appear[i] not in vanish array, then must be empty square on other board
+ m.appear.forEach(psq => {
+ if (this.board[psq.x][psq.y] != VariantRules.EMPTY &&
+ ![m.vanish[0].y,m.vanish[1].y].includes(psq.y))
+ {
+ return false;
+ }
+ });
+ }
+ else if (this.board[m.end.x][m.end.y] != VariantRules.EMPTY)
+ {
+ // Attempt to capture
const piece = this.getPiece(m.end.x,m.end.y);
if ((mirrorSide==1 && Object.keys(VariantRules.ALICE_PIECES).includes(piece))
|| (mirrorSide==2 && Object.keys(VariantRules.ALICE_CODES).includes(piece)))
const piece = this.getPiece(m.end.x,m.end.y);
if ((mirrorSide==1 && Object.keys(VariantRules.ALICE_PIECES).includes(piece))
|| (mirrorSide==2 && Object.keys(VariantRules.ALICE_CODES).includes(piece)))