var util = require('chessground/util');

function capture(ctrl, key) {
  var exploding = [];
  var diff = {};
  var orig = util.key2pos(key);
  var minX = Math.max(1, orig[0] - 1),
      maxX = Math.min(8, orig[0] + 1),
      minY = Math.max(1, orig[1] - 1),
      maxY = Math.min(8, orig[1] + 1);

  for (var x = minX; x <= maxX; x++) {
    for (var y = minY; y <= maxY; y++) {
      var k = util.pos2key([x, y]);
      if (k) {
        exploding.push(k);
        var explodes = ctrl.chessground.state.pieces[k] && (
          k === key || ctrl.chessground.state.pieces[k].role !== 'pawn')
        if (explodes) diff[k] = null;
      }
    }
  }
  ctrl.chessground.setPieces(diff);
  ctrl.chessground.explode(exploding);
}

// needs to explicitly destroy the capturing pawn
function enpassant(ctrl, key, color) {
  var pos = util.key2pos(key);
  var pawnPos = [pos[0], pos[1] + (color === 'white' ? -1 : 1)];
  capture(ctrl, util.pos2key(pawnPos));
}

module.exports = {
  capture: capture,
  enpassant: enpassant
};

@@ -178,18 +178,16 @@
 1),%0A    
-  
 maxX = M
@@ -215,18 +215,16 @@
 1),%0A    
- 
- 
 minY = M
@@ -252,18 +252,16 @@
 1),%0A    
- 
- 
 maxY = M
@@ -284,16 +284,62 @@
 1%5D + 1);
+%0A  var pieces = ctrl.chessground.state.pieces;
 %0A%0A  for 
@@ -452,25 +452,8 @@
 %5D);%0A
-      if (k) %7B%0A  
     
@@ -475,26 +475,24 @@
 h(k);%0A      
-  
 var explodes
@@ -494,39 +494,16 @@
 lodes = 
-ctrl.chessground.state.
 pieces%5Bk
@@ -517,18 +517,16 @@
         
-  
 k === ke
@@ -530,39 +530,16 @@
  key %7C%7C 
-ctrl.chessground.state.
 pieces%5Bk
@@ -563,18 +563,16 @@
 )%0A      
-  
 if (expl
@@ -591,21 +591,14 @@
 %5D = 
-null;%0A      %7D
+false;
 %0A   

tweak round atomic.js