<commit_before>'use strict';

module.exports = Pawn;

var util       = require('util'),
    Board      = require('./board.js'),
    piece      = require('./piece.js'),
    Piece      = piece.Piece,
    PieceColor = piece.PieceColor;

/**
 * Constructor for {Pawn} class
 * @constructor
 */
function Pawn(color) {
  Piece.call(this, color);
  this.notation = this.color === PieceColor.White ? 'P' : 'p';
}

util.inherits(Pawn, Piece);

/**
 * Gets pawn default motions from source square
 * @returns {Array}
 */
Pawn.prototype.getMotions = function(src) {
  var pos = Board.san2Pos(src);
  var motions = [
            [0,2],
     [-1,1],[0,1],[1,1]
          /*[src]*/
  ].map(function(m) {
    return Board.pos2San(pos.x + m[0], pos.y + this._negateIfBlack(m[1]));
  }.bind(this));

  return motions;
};

Pawn.prototype._negateIfBlack = function(posY) {
  posY *= (this.color === PieceColor.Black ? -1 : 1);
  return posY;
}
<commit_msg>refactor pawn module<commit_after>'use strict';

module.exports = Pawn;

var util       = require('util'),
    Board      = require('./board.js'),
    piece      = require('./piece.js'),
    Piece      = piece.Piece,
    PieceColor = piece.PieceColor;

/**
 * Constructor for {Pawn} class
 * @constructor
 */
function Pawn(color) {
  Piece.call(this, color);
  this.notation = this.color === PieceColor.White ? 'P' : 'p';
}

util.inherits(Pawn, Piece);

/**
 * Gets pawn default motions from source square
 * @returns {Array}
 */
Pawn.prototype.getMotions = function(src) {
  var pos = Board.san2Pos(src);
  return [
            [0,2],
     [-1,1],[0,1],[1,1]
          /*[src]*/
  ].map(function(m) {
    return Board.pos2San(pos.x + m[0], pos.y + this._negateIfBlack(m[1]));
  }.bind(this));
};

Pawn.prototype._negateIfBlack = function(posY) {
  posY *= this.color === PieceColor.Black ? -1 : 1;
  return posY;
}

{'fraction_non_alphanumeric': 0.18564490016189963, 'fraction_numerical': 0.015110631408526714, 'mean_word_length': 2.9279661016949152, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3890494', 'n_tokens_mistral': 692, 'n_tokens_neox': 673, 'n_words': 135}