upgrade chessli and puzzles

This commit is contained in:
Thibault Duplessis 2014-11-24 23:51:01 +01:00
parent 9688b1ee28
commit 000b9a3f44
4 changed files with 4 additions and 33 deletions

View file

@ -21,20 +21,6 @@ module.exports = function(cfg, router, i18n, onChange) {
comments: true
};
var chessToDests = function(chess) {
var dests = {};
chess.SQUARES.forEach(function(s) {
var ms = chess.moves({
square: s,
verbose: true
});
if (ms.length) dests[s] = ms.map(function(m) {
return m.to;
});
});
return dests;
}
var situationCache = {};
var showGround = function() {
var moves = this.analyse.moveList(this.vm.path);
@ -65,7 +51,7 @@ module.exports = function(cfg, router, i18n, onChange) {
turnColor: turnColor,
movable: {
color: turnColor,
dests: chessToDests(chess)
dests: chess.dests()
},
check: chess.in_check(),
lastMove: [lm.from, lm.to]

@ -1 +1 @@
Subproject commit 8c81c675cb93679f993a5a977d7d8086a0c542fd
Subproject commit 25b301f693f45458fee621a9d0ce6662101f0cc8

View file

@ -1,5 +1,3 @@
var groupBy = require('lodash-node/modern/collections/groupBy')
var mapValues = require('lodash-node/modern/objects/mapValues')
var Chess = require('chessli.js').Chess;
function make(fen) {
@ -19,18 +17,6 @@ function parseMove(m) {
return m ? [m.from, m.to] : null;
}
function dests(c) {
var moves = c.moves({
verbose: true
});
var grouped = groupBy(moves.map(parseMove), function(m) {
return m[0];
});
return mapValues(grouped, function(ms) {
return ms.map(function(m) { return m[1]; });
});
}
function lastMove(c) {
var hist = c.history({
verbose: true
@ -42,6 +28,5 @@ module.exports = {
make: make,
move: move,
parseMove: parseMove,
dests: dests,
lastMove: lastMove
};

View file

@ -49,7 +49,7 @@ module.exports = function(cfg, router, i18n) {
turnColor: this.data.puzzle.color,
check: null,
movable: {
dests: chess.dests(this.data.chess)
dests: this.data.chess.dests()
}
});
if (this.data.chess.in_check()) this.chessground.setCheck();
@ -107,7 +107,7 @@ module.exports = function(cfg, router, i18n) {
fen: this.data.chess.fen(),
lastMove: move,
movable: {
dests: chess.dests(this.data.chess)
dests: this.data.chess.dests()
},
turnColor: this.data.puzzle.color,
check: null