Code coverage report for lib/piece/pawn.js

Statements: 100% (20 / 20)      Branches: 100% (15 / 15)      Functions: 100% (8 / 8)      Lines: 100% (20 / 20)      Ignored: none     

All files » lib/piece/ » pawn.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41  1   3       1 1 1 1 34183   1 1   1905     65     1668     168 103   65 65 64   1     1527     76965    
"use strict";
Object.defineProperties(exports, {
  Pawn: {get: function() {
      return Pawn;
    }},
  __esModule: {value: true}
});
var PAWN = require('../brands').PAWN;
var Piece = require('./piece').Piece;
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;
    }
    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);