fix atomic UI explosions

This commit is contained in:
Thibault Duplessis 2015-01-02 17:02:43 +01:00
parent 88732e05b9
commit a1d7c391cb
7 changed files with 17 additions and 12 deletions

File diff suppressed because one or more lines are too long

View file

@ -30,7 +30,7 @@
"watchify": "^1.0.2"
},
"dependencies": {
"chessground": "1.8.4",
"chessground": "1.8.6",
"chessli.js": "file:../chessli",
"game": "file:../game",
"lodash-node": "^2.4.1",

View file

@ -30,7 +30,7 @@
"watchify": "^1.0.2"
},
"dependencies": {
"chessground": "1.8.4",
"chessground": "1.8.6",
"lodash-node": "^2.4.1",
"mithril": "0.1.27"
}

View file

@ -30,7 +30,7 @@
"watchify": "^1.0.2"
},
"dependencies": {
"chessground": "1.8.4",
"chessground": "1.8.6",
"lodash-node": "^2.4.1",
"mithril": "0.1.27"
}

View file

@ -30,7 +30,7 @@
"watchify": "^1.0.2"
},
"dependencies": {
"chessground": "1.8.4",
"chessground": "1.8.6",
"chessli.js": "file:../chessli",
"lodash-node": "^2.4.1",
"merge": "^1.2.0",

View file

@ -30,7 +30,7 @@
"watchify": "^1.0.2"
},
"dependencies": {
"chessground": "1.8.4",
"chessground": "1.8.6",
"chessli.js": "file:../chessli",
"game": "file:../game",
"lodash-node": "^2.4.1",

View file

@ -1,15 +1,20 @@
var util = require('chessground').util;
function capture(ctrl, key) {
var ps = [];
var pos = util.key2pos(key);
var exploding = [];
var diff = {};
var orig = util.key2pos(key);
for (var x = -1; x < 2; x++) {
for (var y = -1; y < 2; y++) {
var p = util.pos2key([pos[0] + x, pos[1] + y]);
if (p) ps.push(p);
var key = util.pos2key([orig[0] + x, orig[1] + y]);
if (key) {
exploding.push(key);
if (ctrl.chessground.data.pieces[key] && ctrl.chessground.data.pieces[key].role !== 'pawn') diff[key] = null;
}
}
}
ctrl.chessground.explode(ps);
ctrl.chessground.setPieces(diff);
ctrl.chessground.explode(exploding);
};
module.exports = {