/* pieces.js – simple data holders + starting layout */
function Piece(kind, colour) {
  var newpiece = { kind, colour}

  newpiece.sprite = colour + '_' + kind;  // for draw2d.image
  newpiece.captured = false;
  newpiece.coord    = [0,0];

  return newpiece
}

function startingPosition(grid) {
  var W = 'white', B = 'black', x;

  // pawns
  for (x = 0; x < 8; x++) {
    grid.add(Piece('pawn', W), [x, 6]);
    grid.add(Piece('pawn', B), [x, 1]);
  }
  // major pieces
  var back = ['rook','knight','bishop','queen','king','bishop','knight','rook'];
  for (x = 0; x < 8; x++) {
    grid.add(Piece(back[x], W), [x, 7]);
    grid.add(Piece(back[x], B), [x, 0]);
  }
}

return { Piece, startingPosition };
