<commit_before>import SPELLS from 'common/SPELLS';
import Module from 'Parser/Core/Module';

class AtonementSource extends Module {
  _previousDamageEvent = null;
  _previousAtonementApplicator = null;
  _previousAtonementApplicatorEvent = null;

  // Spells that will apply atonement
  atonementApplicators = new Map([
    [SPELLS.POWER_WORD_RADIANCE.id, SPELLS.POWER_WORD_RADIANCE.atonementDuration],
    [SPELLS.POWER_WORD_SHIELD.id, SPELLS.POWER_WORD_SHIELD.atonementDuration],
    [SPELLS.PLEA.id, SPELLS.PLEA.atonementDuration],
    [SPELLS.SHADOW_MEND.id, SPELLS.SHADOW_MEND.atonementDuration],
  ]);

  get atonementDuration() {
    return this.atonementApplicators;
  }

  get atonementDamageSource() {
    return this._previousDamageEvent;
  }

  get atonementApplicationSource() {
    return this._previousAtonementApplicator;
  }

  get atonementApplicationSourceEvent() {
    return this._previousAtonementApplicatorEvent;
  }

  on_byPlayer_heal(event) {
    if (this.atonementApplicators.has(event.ability.guid)) {
      this._previousAtonementApplicator = event.ability.guid;
      this._previousAtonementApplicatorEvent = event;
    }
  }
  
  on_byPlayer_applybuff(event) {
    if (this.atonementApplicators.has(event.ability.guid)) {
      this._previousAtonementApplicator = event.ability.guid;
      this._previousAtonementApplicatorEvent = event;
    }
  }

  on_byPlayer_damage(event) {
    // Some Atonement events have the type 'damage', this prevents them registering as a source
    if (event.ability.guid === SPELLS.ATONEMENT_HEAL_NON_CRIT.id) {
      return;
    }
    this._previousDamageEvent = event;
  }
}

export default AtonementSource;<commit_msg>Disc Priest: friendly fire doesn't trigger Atonement healing<commit_after>import SPELLS from 'common/SPELLS';
import Module from 'Parser/Core/Module';

class AtonementSource extends Module {
  _previousDamageEvent = null;
  _previousAtonementApplicator = null;
  _previousAtonementApplicatorEvent = null;

  // Spells that will apply atonement
  atonementApplicators = new Map([
    [SPELLS.POWER_WORD_RADIANCE.id, SPELLS.POWER_WORD_RADIANCE.atonementDuration],
    [SPELLS.POWER_WORD_SHIELD.id, SPELLS.POWER_WORD_SHIELD.atonementDuration],
    [SPELLS.PLEA.id, SPELLS.PLEA.atonementDuration],
    [SPELLS.SHADOW_MEND.id, SPELLS.SHADOW_MEND.atonementDuration],
  ]);

  get atonementDuration() {
    return this.atonementApplicators;
  }

  get atonementDamageSource() {
    return this._previousDamageEvent;
  }

  get atonementApplicationSource() {
    return this._previousAtonementApplicator;
  }

  get atonementApplicationSourceEvent() {
    return this._previousAtonementApplicatorEvent;
  }

  on_byPlayer_heal(event) {
    if (this.atonementApplicators.has(event.ability.guid)) {
      this._previousAtonementApplicator = event.ability.guid;
      this._previousAtonementApplicatorEvent = event;
    }
  }
  
  on_byPlayer_applybuff(event) {
    if (this.atonementApplicators.has(event.ability.guid)) {
      this._previousAtonementApplicator = event.ability.guid;
      this._previousAtonementApplicatorEvent = event;
    }
  }

  on_byPlayer_damage(event) {
    // Some Atonement events have the type 'damage', this prevents them registering as a source
    if (event.ability.guid === SPELLS.ATONEMENT_HEAL_NON_CRIT.id) {
      return;
    }
    if (event.targetIsFriendly) {
      // Friendly fire doesn't atonement transfer - I think. The only place I could find this is Aura of Sacrifice so it might also be restricted by spells not owned by the player (even though the player is the damage source), but that seems less likely.
      return;
    }
    this._previousDamageEvent = event;
  }
}

export default AtonementSource;
{'fraction_non_alphanumeric': 0.08678130037614186, 'fraction_numerical': 0.0, 'mean_word_length': 4.192468619246862, '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': '5526651', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1231, 'n_words': 229}