Code coverage report for lib/piece/mobility/royal.js

Statements: 98.33% (59 / 60)      Branches: 100% (20 / 20)      Functions: 88.89% (8 / 9)      Lines: 98.33% (59 / 60)      Ignored: none     

All files » lib/piece/mobility/ » royal.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 102 103 104 105  1   1       1     1 1     1 1 8576   1 1   475                 475 4107 20148   475 475 475   475 475 475   1378 1378   930 930 930   930 930 930   4562 4562   3659 3659 3659   3659 3659   3632 3632 3632   448               1 8576 8576   1 434 842 1684   434 434   410 410   408 408 408   432       1 4288 4288 4288 4288    
"use strict";
Object.defineProperties(exports, {
  Royal: {get: function() {
      return Royal;
    }},
  __esModule: {value: true}
});
var $__0 = require('../../brands'),
    KINGSIDE = $__0.KINGSIDE,
    QUEENSIDE = $__0.QUEENSIDE;
var Point = require('../../point').Point;
var $__2 = require('../mobility'),
    Mobility = $__2.Mobility,
    quadrants = $__2.quadrants;
var Castling = require('../../castling').Castling;
var RoyalMobility = function RoyalMobility() {
  $traceurRuntime.defaultSuperCall(this, $RoyalMobility.prototype, arguments);
};
var $RoyalMobility = RoyalMobility;
($traceurRuntime.createClass)(RoyalMobility, {
  adjacentPoints: $traceurRuntime.initGeneratorFunction(function $__10(position, p0) {
    var $__9,
        m,
        n,
        $__7,
        $__8,
        o,
        $__5,
        $__6,
        p1;
    return $traceurRuntime.createGeneratorInstance(function($ctx) {
      while (true)
        switch ($ctx.state) {
          case 0:
            $__9 = this, m = $__9.m, n = $__9.n;
            $ctx.state = 14;
            break;
          case 14:
            $__7 = [new Point(m, n), new Point(n, m)][$traceurRuntime.toProperty(Symbol.iterator)]();
            $ctx.state = 7;
            break;
          case 7:
            $ctx.state = (!($__8 = $__7.next()).done) ? 9 : -2;
            break;
          case 9:
            o = $__8.value;
            $ctx.state = 10;
            break;
          case 10:
            $__5 = quadrants[$traceurRuntime.toProperty(Symbol.iterator)]();
            $ctx.state = 4;
            break;
          case 4:
            $ctx.state = (!($__6 = $__5.next()).done) ? 5 : 7;
            break;
          case 5:
            p1 = $__6.value;
            $ctx.state = 6;
            break;
          case 6:
            $ctx.state = 2;
            return p0.sum(p1.product(o));
          case 2:
            $ctx.maybeThrow();
            $ctx.state = 4;
            break;
          default:
            return $ctx.end();
        }
    }, $__10, this);
  }),
  toString: function() {
    return 'royal';
  }
}, {}, Mobility);
var CastlingMobility = function CastlingMobility(color, side) {
  this.color = color;
  this.side = side;
};
($traceurRuntime.createClass)(CastlingMobility, {adjacentPoints: $traceurRuntime.initGeneratorFunction(function $__11(position, p0) {
    return $traceurRuntime.createGeneratorInstance(function($ctx) {
      while (true)
        switch ($ctx.state) {
          case 0:
            $ctx.state = (position.castling.isLegal(this.color, this.side)) ? 1 : -2;
            break;
          case 1:
            $ctx.state = 2;
            return p0.sum(Castling.kingOffset(this.color, this.side));
          case 2:
            $ctx.maybeThrow();
            $ctx.state = -2;
            break;
          default:
            return $ctx.end();
        }
    }, $__11, this);
  })}, {}, Mobility);
function Royal() {
  this.mobility.push(new RoyalMobility(1, 0));
  this.mobility.push(new RoyalMobility(1, 1));
  this.mobility.push(new CastlingMobility(this.color, KINGSIDE));
  this.mobility.push(new CastlingMobility(this.color, QUEENSIDE));
}