Code coverage report for lib/pawn.js

Statements: 100% (21 / 21)      Branches: 100% (16 / 16)      Functions: 100% (8 / 8)      Lines: 100% (21 / 21)      Ignored: none     

All files » lib/ » 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 42  1   3       1 1 1 1 1 35511   1 1   3233     563     15606     2117 1554   563 563 428   135     14751     141847    
"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);