"use strict";
Object.defineProperties(exports, {
Line: {get: function() {
return Line;
}},
__esModule: {value: true}
});
var FEN = require('./fen').FEN;
var last = require('./util').last;
var Line = function Line() {
var position = arguments[0] !== (void 0) ? arguments[0] : FEN.standardPosition;
this.position = position;
this.ply = [];
};
($traceurRuntime.createClass)(Line, {
addPly: function(ply) {
this.ply.push(ply);
},
move: function(move) {
var note = arguments[1] !== (void 0) ? arguments[1] : null;
var position = this.position.move(move);
this.addPly({
position: position,
move: move,
note: note
});
this.position = position;
return this;
},
annotate: function(note) {
if (this.ply.length === 0) {
throw new Error("no move to annotate");
}
last(this.ply).note = note;
return this;
},
get plyLength() {
return this.ply.length;
},
get length() {
return Math.ceil(this.ply.length / 2);
}
}, {});
|