Code coverage report for lib/piece/piece.js

Statements: 96% (48 / 50)      Branches: 94.44% (17 / 18)      Functions: 80% (8 / 10)      Lines: 96% (48 / 50)      Ignored: none     

All files » lib/piece/ » piece.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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101  1   2       1     1 68349 68349 68349   1   72             72 1113 4680   72 72 72   72 72 72   128 128   57 57 57   57 57 57   1098 1098   1042 1042 1042   1042 1042   1041 1041 1041   71         1874   2749   2749 2749     2749 2749 355           1519     1677           5532           116858      
"use strict";
Object.defineProperties(exports, {
  Piece: {get: function() {
      return Piece;
    }},
  __esModule: {value: true}
});
var $__0 = require('../brands'),
    WHITE = $__0.WHITE,
    BLACK = $__0.BLACK;
var Piece = function Piece() {
  var color = $traceurRuntime.assertObject(arguments[0] !== (void 0) ? arguments[0] : {}).color;
  this.color = color;
  this.mobility = [];
};
($traceurRuntime.createClass)(Piece, {
  moves: $traceurRuntime.initGeneratorFunction(function $__7(position) {
    var loc,
        $__4,
        $__5,
        m,
        $__2,
        $__3,
        move;
    return $traceurRuntime.createGeneratorInstance(function($ctx) {
      while (true)
        switch ($ctx.state) {
          case 0:
            loc = position.pieceCoords(this);
            $ctx.state = 14;
            break;
          case 14:
            $__4 = this.mobility[$traceurRuntime.toProperty(Symbol.iterator)]();
            $ctx.state = 7;
            break;
          case 7:
            $ctx.state = (!($__5 = $__4.next()).done) ? 9 : -2;
            break;
          case 9:
            m = $__5.value;
            $ctx.state = 10;
            break;
          case 10:
            $__2 = m.adjacentPoints(position, loc)[$traceurRuntime.toProperty(Symbol.iterator)]();
            $ctx.state = 4;
            break;
          case 4:
            $ctx.state = (!($__3 = $__2.next()).done) ? 5 : 7;
            break;
          case 5:
            move = $__3.value;
            $ctx.state = 6;
            break;
          case 6:
            $ctx.state = 2;
            return move;
          case 2:
            $ctx.maybeThrow();
            $ctx.state = 4;
            break;
          default:
            return $ctx.end();
        }
    }, $__7, this);
  }),
  canMove: function(position, from, to) {
    for (var $__2 = this.mobility[$traceurRuntime.toProperty(Symbol.iterator)](),
        $__3; !($__3 = $__2.next()).done; ) {
      var m = $__3.value;
      {
        try {
          throw undefined;
        } catch (success) {
          {
            success = m.test(position, from, to);
            if (success) {
              return true;
            }
          }
        }
      }
    }
    return false;
  },
  canCapture: function(position, from, to) {
    return this.canMove(position, from, to);
  },
  toString: function() {
    return this.constructor.name;
  },
  get isWhite() {
    return this.color === WHITE;
  },
  get isBlack() {
    return this.color === BLACK;
  },
  get brand() {
    return this.constructor.brand;
  }
}, {});