Skip to content

Commit

Permalink
switch enemy "type" usage to "subType" (WoWAnalyzer#6750)
Browse files Browse the repository at this point in the history
* switch enemy "type" usage to "subType"

tl;dr - in v1 the "type" field is actualy "subType". I mapped subType
to type for Players but not enemies/pets. that mostly doesn't matter
because they always match---*except* for bosses.

this fixes several cases where boss/add-related code broke because it
was looking at the wrong field

* couple of missed spots

* changelog entry
  • Loading branch information
emallson authored May 2, 2024
1 parent 74294f1 commit b1abc13
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/CHANGELOG.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import SpellLink from 'interface/SpellLink';

// prettier-ignore
export default [
change(date(2024, 5, 2), 'Fix issue with boss detection', emallson),
change(date(2024, 4, 26), 'Actually fix friendly/enemy determination', emallson),
change(date(2024, 4, 22), 'Improve display of dense performance boxes', emallson),
change(date(2024, 4, 24), 'Bump for season 4 start.', ToppleTheNun),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class DrainSoul extends Analyzer {
onFinished() {
const allEnemies = this.enemies.getEntities();
this.totalNumOfAdds = Object.values(allEnemies)
.filter((enemy) => enemy.type === 'NPC')
.filter((enemy) => enemy.subType === 'NPC')
.reduce((count, enemy) => count + enemy._baseInfo.fights[0].instances, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class BuffTargetHelper extends Analyzer {
filterBossDamage: boolean = false;
nameFilter: string = '';
bossFilter: string = this.owner.report.enemies
.filter((enemy) => enemy.type === 'Boss')
.filter((enemy) => enemy.subType === 'Boss')
.map((enemy) => `${enemy.guid}`)
.join(',');
abilityBlacklist: string = [...ABILITY_BLACKLIST].join(', ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CarefulAim extends ExecuteHelper {
this.active = this.selectedCombatant.hasTalent(TALENTS_HUNTER.CAREFUL_AIM_TALENT);
this.owner.report.enemies.forEach((enemy) => {
enemy.fights.forEach((fight) => {
if (fight.id === this.owner.fight.id && enemy.type === 'Boss') {
if (fight.id === this.owner.fight.id && enemy.subType === 'Boss') {
this.bossIDs.push(enemy.id);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class DrainSoul extends Analyzer {
if (!enemy) {
return;
}
if (enemy.type.toLowerCase() === 'boss' && !this._lastEnergizeWasted) {
if (enemy.subType.toLowerCase() === 'boss' && !this._lastEnergizeWasted) {
// it's a boss kill and we didn't waste the shard, subtract it
this._subtractBossShards += 1;
}
Expand All @@ -87,7 +87,7 @@ class DrainSoul extends Analyzer {
onFinished() {
const allEnemies = this.enemies.getEntities();
this.totalNumOfAdds = Object.values(allEnemies)
.filter((enemy) => enemy.type === 'NPC')
.filter((enemy) => enemy.subType === 'NPC')
.reduce((count, enemy) => count + enemy._baseInfo.fights[0].instances, 0);
this._shardsGained =
this.soulShardTracker.getGeneratedBySpell(SPELLS.DRAIN_SOUL_KILL_SHARD_GEN.id) -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class PrepullPetNormalizer extends EventsNormalizer {
petOwner: this.owner.playerId,
fights: [],
type: 'faketype',
subType: 'faketype',
icon: spell.icon,
},
timestamp: this.owner.fight.start_time,
Expand Down
2 changes: 1 addition & 1 deletion src/interface/EventsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const EntityCell = ({ entity }: { entity: PlayerInfo | PetInfo | EnemyInfo | nul
if (!entity) {
return null;
}
return <span className={entity.type}>{entity.name}</span>;
return <span className={entity.subType || entity.type}>{entity.name}</span>;
};

const AbilityCell = ({ ability }: { ability: Ability | null }) => {
Expand Down
6 changes: 6 additions & 0 deletions src/parser/core/Enemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ class Enemy extends Entity {
return this._baseInfo.name;
}

/** Generally "NPC" */
get type() {
return this._baseInfo.type;
}

/** Generally "Boss" or "NPC" */
get subType() {
return this._baseInfo.subType;
}

get guid() {
return this._baseInfo.guid;
}
Expand Down
1 change: 1 addition & 0 deletions src/parser/core/Unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ interface Unit {
id: number;
guid: number;
type: string;
subType: string;
icon: string;
}

Expand Down
1 change: 1 addition & 0 deletions src/parser/core/tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const DEFAULT_PLAYER_INFO: PlayerInfo = {
id: 1,
name: '',
type: '',
subType: '',
};

export const DEFAULT_FIGHT: Fight = {
Expand Down

0 comments on commit b1abc13

Please sign in to comment.