"use strict";
Object.defineProperties(exports, {
Pawn: {get: function() {
return Pawn;
}},
__esModule: {value: true}
});
var PAWN = require('./brands').PAWN;
var Piece = require('./piece').Piece;
var Point = require('./point').Point;
var squareName = require('./util').squareName;
var Pawn = function Pawn() {
$traceurRuntime.defaultSuperCall(this, $Pawn.prototype, arguments);
};
var $Pawn = Pawn;
($traceurRuntime.createClass)(Pawn, {
get fenEncoding() {
return this.isWhite ? 'P' : 'p';
},
get homeRank() {
return this.isWhite ? 6 : 1;
},
get reach() {
return this.isWhite ? -1 : 1;
},
canMove: function(position, from, to) {
if (from.x !== to.x) {
return false;
}
var reach = this.reach;
if (from.y === this.homeRank) {
return to.y === from.y + reach || ((to.y === from.y + reach * 2) && (position.pieceByCoords(new Point(from.x, from.y + reach)) == null));
}
return to.y === from.y + reach;
},
canCapture: function(position, from, to) {
return (to.y === from.y + this.reach && (from.x === to.x + 1 || from.x === to.x - 1));
}
}, {get brand() {
return PAWN;
}}, Piece);
|