<commit_before>Werld.Views.Creature = Werld.Views.Base.Creature.extend({
  initialize: function() {
    Werld.Views.Creature.__super__.initialize.call(this);

    this.model.bind('change:status', this.onModelStatusChange, this);

    this.hitPointsBarRectangleWidth = 50;
    this.hitPointsBarRectangle = new Rectangle(
      this.container.x -
        ((this.hitPointsBarRectangleWidth - Werld.Config.PIXELS_PER_TILE) / 2),
      -0.21 * Math.pow(this.model.get('SPRITE').DIMENSIONS[1], 5 / 4),
      this.hitPointsBarRectangleWidth,
      6
    );
    this.hitPointsBarGraphics = new Graphics();
    this.hitPointsBar = new Shape(this.hitPointsBarGraphics);
    this.hitPointsBar.alpha = 0.7;

    this.container.addChild(this.hitPointsBar);
    this.hitPointsBar.tick = _.bind(this.hitPointsBarTick, this);
  },
  characterNameTextTick: function() {
    Werld.Views.Character.__super__.characterNameTextTick.call(this);
    this.characterNameText.color = '#cccccc';
    this.characterNameText.font = '16px "PowellAntique" serif';
  },
  _characterNameText: function() {
    if (this.model.alive()) {
      return(this.model.get('name'));
    } else {
      return(this.model.get('name') + ' corpse');
    }
  },
  hitPointsBarTick: function() {
    var hitPointsPercentage =
      this.model.get('hitPoints') / this.model.get('maxHitPoints');
    this.hitPointsBarRectangle.width =
      hitPointsPercentage * this.hitPointsBarRectangleWidth;
    this.hitPointsBarGraphics.clear();

    if (this.hitPointsBarRectangle.width > 0) {
      this.hitPointsBarGraphics.
        beginFill('red').
        beginStroke('black').
        drawRoundRect(
          this.hitPointsBarRectangle.x,
          this.hitPointsBarRectangle.y,
          this.hitPointsBarRectangle.width,
          this.hitPointsBarRectangle.height,
          1
        ).
        endStroke().
        endFill();
    }
  },
  onModelStatusChange: function() {
    if (this.model.dead()) {
      if (this.model.tileDistance(Werld.character) <= 1) {<commit_msg>Only redraw creature's hit points bar when hit points change.<commit_after>Werld.Views.Creature = Werld.Views.Base.Creature.extend({
  initialize: function() {
    Werld.Views.Creature.__super__.initialize.call(this);

    this.model.bind('change:status', this.onModelStatusChange);
    this.model.bind('change:hitPoints', this.updateHitPointsBar);

    this.hitPointsBarRectangleWidth = 50;
    this.hitPointsBarRectangle = new Rectangle(
      this.container.x -
        ((this.hitPointsBarRectangleWidth - Werld.Config.PIXELS_PER_TILE) / 2),
      -0.21 * Math.pow(this.model.get('SPRITE').DIMENSIONS[1], 5 / 4),
      this.hitPointsBarRectangleWidth,
      6
    );
    this.hitPointsBarGraphics = new Graphics();
    this.hitPointsBar = new Shape(this.hitPointsBarGraphics);
    this.hitPointsBar.alpha = 0.7;

    this.container.addChild(this.hitPointsBar);

    this.updateHitPointsBar(this.model);
  },
  characterNameTextTick: function() {
    Werld.Views.Character.__super__.characterNameTextTick.call(this);
    this.characterNameText.color = '#cccccc';
    this.characterNameText.font = '16px "PowellAntique" serif';
  },
  _characterNameText: function() {
    if (this.model.alive()) {
      return(this.model.get('name'));
    } else {
      return(this.model.get('name') + ' corpse');
    }
  },
  updateHitPointsBar: function(model) {
    var hitPointsPercentage =
      this.model.get('hitPoints') / this.model.get('maxHitPoints');
    this.hitPointsBarRectangle.width =
      hitPointsPercentage * this.hitPointsBarRectangleWidth;
    this.hitPointsBarGraphics.clear();

    if (this.hitPointsBarRectangle.width > 0) {
      this.hitPointsBarGraphics.
        beginFill('red').
        beginStroke('black').
        drawRoundRect(
          this.hitPointsBarRectangle.x,
          this.hitPointsBarRectangle.y,
          this.hitPointsBarRectangle.width,
          this.hitPointsBarRectangle.height,
          1
        ).
        endStroke().
        endFill();
    }
  },
  onModelStatusChange: function() {
    if (this.model.dead()) {
      if (this.model.tileDistance(Werld.character) <= 1) {
{'fraction_non_alphanumeric': 0.13119110896351777, 'fraction_numerical': 0.008214544575984537, 'mean_word_length': 3.1608040201005023, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2604023', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1310, 'n_words': 174}