<commit_before>function Yeti(options) {
  this.x = 4;
  this.y = 10;
  this.width = 43;
  this.height = 32;
  this.aggressive = false;
  this.context = options.context;
  this.position = 0;
}

Yeti.prototype.attack = function(skier, skierImg) {
  posYeti(this);
  var direction = skier.x - this.x;

  drawYeti(this, direction, skierImg);

  this.rotation = Math.atan2(skier.y - this.y, skier.x - this.x);
  this.x += Math.cos(this.rotation);
  this.y += Math.sin(this.rotation);
  return this;
};

function posYeti(yeti) {
  yeti.position += 1;
  if (yeti.position > 16) {
    return yeti.position = 0;
  }
}

function drawYeti(yeti, direction, skierImg) {
  if (yeti.position < 8 && direction > 0) {
    yetiRunning(64, 113, 25, yeti, skierImg);
  } else if (yeti.position > 8 && direction > 0) {
    yetiRunning(90, 113, 32, yeti, skierImg);
  } else if (yeti.position < 8 && direction < 0) {
    yetiRunning(64, 159, 25, yeti, skierImg);
  } else {
    yetiRunning(90, 159, 32, yeti, skierImg);
  }
}

function yetiRunning(posx, posy, width, yeti, skierImg) {
  yeti.context.drawImage(
  skierImg,
  posx,
  posy,<commit_msg>Additional refactor for when the yeti moves left vs right.<commit_after>function Yeti(options) {
  this.x = 4;
  this.y = 10;
  this.width = 43;
  this.height = 32;
  this.aggressive = false;
  this.context = options.context;
  this.position = 0;
}

Yeti.prototype.attack = function(skier, skierImg) {
  posYeti(this);
  var direction = skier.x - this.x;

  drawYeti(this, direction, skierImg);

  this.rotation = Math.atan2(skier.y - this.y, skier.x - this.x);
  this.x += Math.cos(this.rotation);
  this.y += Math.sin(this.rotation);
  return this;
};

function posYeti(yeti) {
  yeti.position += 1;
  if (yeti.position > 16) {
    return yeti.position = 0;
  }
}

function drawYeti(yeti, direction, skierImg) {
  if (direction > 0) {
    moveRight(yeti, skierImg);
  } else {
    moveLeft(yeti, skierImg);
  }
}

function moveRight(yeti, skierImg) {
  if (yeti.position < 8) {
    yetiRunning(64, 113, 25, yeti, skierImg);
  } else {
    yetiRunning(90, 113, 32, yeti, skierImg);
  }
}

function moveLeft(yeti, skierImg) {
  if (yeti.position < 8) {
    yetiRunning(64, 159, 25, yeti, skierImg);
  } else {
    yetiRunning(90, 159, 32, yeti, skierImg);
  }
}

function yetiRunning(posx, posy, width, yeti, skierImg) {
  yeti.context.drawImage(
  skierImg,
  posx,
  posy,
{'fraction_non_alphanumeric': 0.15029142381348876, 'fraction_numerical': 0.03788509575353872, 'mean_word_length': 3.369090909090909, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, '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': '1724314', 'n_tokens_mistral': 1047, 'n_tokens_neox': 956, 'n_words': 212}