Code coverage report for lib/line.js

Statements: 100% (21 / 21)      Branches: 66.67% (4 / 6)      Functions: 100% (7 / 7)      Lines: 100% (21 / 21)      Ignored: none     

All files » lib/ » line.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  1   2       1 1 1 19 19 19   1   1115     1118 1118 1115         1115 1115     10 1   9 9     1     1      
"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);
  }
}, {});