"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;
}
}, {});
|