Skip to content

Commit

Permalink
Merge pull request wowsims#432 from wowsims/raid-vis-fixes
Browse files Browse the repository at this point in the history
clean up damage table
  • Loading branch information
rosenrusinov authored May 12, 2024
2 parents d1da337 + 52f60d6 commit 7fd2165
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 38 deletions.
25 changes: 9 additions & 16 deletions ui/core/components/detailed_results/player_damage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export class PlayerDamageMetricsTable extends MetricsTable<UnitMetrics> {
},
});

const playerActions = player.getPlayerAndPetActions().map(action => action.forTarget(this.resultsFilter.getFilter())).flat();
const playerDps = sum(playerActions.map(action => action.dps))
const playerDps = this.getPlayerDps(player)
cellElem.innerHTML = `
<div class="player-damage-percent">
<span>${(playerDps / this.raidDps * 100).toFixed(2)}%</span>
Expand All @@ -65,23 +64,21 @@ export class PlayerDamageMetricsTable extends MetricsTable<UnitMetrics> {
tooltip: 'Damage / Encounter Duration',
columnClass: 'dps-cell',
sort: ColumnSortType.Descending,
getValue: (player: UnitMetrics) => {
const playerActions = player.getPlayerAndPetActions().map(action => action.forTarget(this.resultsFilter.getFilter())).flat();
const playerDps = sum(playerActions.map(action => action.dps))
return playerDps
},
getDisplayString: (player: UnitMetrics) => {
const playerActions = player.getPlayerAndPetActions().map(action => action.forTarget(this.resultsFilter.getFilter())).flat();
const playerDps = sum(playerActions.map(action => action.dps))
return playerDps.toFixed(1)
},
getValue: (player: UnitMetrics) => this.getPlayerDps(player),
getDisplayString: (player: UnitMetrics) => this.getPlayerDps(player).toFixed(1),
},
]);
this.resultsFilter = resultsFilter;
this.raidDps = 0;
this.maxDps = 0;
}

private getPlayerDps(player:UnitMetrics): number {
const playerActions = player.getPlayerAndPetActions().map(action => action.forTarget(this.resultsFilter.getFilter())).flat();
const playerDps = sum(playerActions.map(action => action.dps))
return playerDps
}

customizeRowElem(player: UnitMetrics, rowElem: HTMLElement) {
rowElem.classList.add('player-damage-row');
rowElem.addEventListener('click', event => {
Expand All @@ -92,10 +89,6 @@ export class PlayerDamageMetricsTable extends MetricsTable<UnitMetrics> {
getGroupedMetrics(resultData: SimResultData): Array<Array<UnitMetrics>> {
const players = resultData.result.getPlayers(resultData.filter);

//this.raidDps = resultData.result.raidMetrics.dps.avg;
//const maxDpsIndex = maxIndex(players.map(player => player.dps.avg))!;
//this.maxDps = players[maxDpsIndex].dps.avg;

const targetActions = players.map(player => player.getPlayerAndPetActions().map(action => action.forTarget(resultData.filter))).flat();

this.raidDps = sum(targetActions.map(action => action.dps));
Expand Down
35 changes: 13 additions & 22 deletions ui/core/components/detailed_results/player_damage_taken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export class PlayerDamageTakenMetricsTable extends MetricsTable<UnitMetrics> {
},
});

const targets = this.resultData!.result.getTargets(this.resultData!.filter);
const targetActions = targets.map(target => target.getMeleeActions().concat(target.getSpellActions()).map(action => action.forTarget({ player: player.unitIndex }))).flat();
const playerDtps = sum(targetActions.map(action => action.dps))
const playerDtps = this.getPlayerDtps(player)
cellElem.innerHTML = `
<div class="player-damage-percent">
<span>${(playerDtps / this.raidDtps * 100).toFixed(2)}%</span>
Expand All @@ -74,25 +72,22 @@ export class PlayerDamageTakenMetricsTable extends MetricsTable<UnitMetrics> {
tooltip: 'Damage Taken / Encounter Duration',
columnClass: 'dps-cell',
sort: ColumnSortType.Descending,
getValue: (player: UnitMetrics) => {
const targets = this.resultData!.result.getTargets(this.resultData!.filter);
const targetActions = targets.map(target => target.getMeleeActions().concat(target.getSpellActions()).map(action => action.forTarget({ player: player.unitIndex }))).flat();
const playerDtps = sum(targetActions.map(action => action.dps))
return playerDtps
},
getDisplayString: (player: UnitMetrics) => {
const targets = this.resultData!.result.getTargets(this.resultData!.filter);
const targetActions = targets.map(target => target.getMeleeActions().concat(target.getSpellActions()).map(action => action.forTarget({ player: player.unitIndex }))).flat();
const playerDtps = sum(targetActions.map(action => action.dps))
return playerDtps.toFixed(1)
},
getValue: (player: UnitMetrics) => this.getPlayerDtps(player),
getDisplayString: (player: UnitMetrics) => this.getPlayerDtps(player).toFixed(1),
},
]);
this.resultsFilter = resultsFilter;
this.raidDtps = 0;
this.maxDtps = 0;
}

private getPlayerDtps(player: UnitMetrics): number {
const targets = this.resultData!.result.getTargets(this.resultData!.filter);
const targetActions = targets.map(target => target.getPlayerAndPetActions().map(action => action.forTarget({ player: player.unitIndex }))).flat();
const playerDtps = sum(targetActions.map(action => action.dps))
return playerDtps
}

customizeRowElem(player: UnitMetrics, rowElem: HTMLElement) {
rowElem.classList.add('player-damage-row');
rowElem.addEventListener('click', event => {
Expand All @@ -104,20 +99,16 @@ export class PlayerDamageTakenMetricsTable extends MetricsTable<UnitMetrics> {
this.resultData = resultData;
const players = resultData.result.getPlayers(resultData.filter);

//this.raidDtps = sum(players.map(player => player.dtps.avg));
//const maxDpsIndex = maxIndex(players.map(player => player.dtps.avg))!;
//this.maxDtps = players[maxDpsIndex].dtps.avg;

const targets = resultData.result.getTargets(resultData.filter);
const targetActions = targets.map(target => target.getMeleeActions().concat(target.getSpellActions()).map(action => action.forTarget(resultData.filter))).flat();
const targetActions = targets.map(target => target.getPlayerAndPetActions().map(action => action.forTarget(resultData.filter))).flat();

this.raidDtps = sum(targetActions.map(action => action.dps));
const maxDpsIndex = maxIndex(players.map(player => {
const targetActions = targets.map(target => target.getMeleeActions().concat(target.getSpellActions()).map(action => action.forTarget({ player: player.unitIndex }))).flat();
const targetActions = targets.map(target => target.getPlayerAndPetActions().map(action => action.forTarget({ player: player.unitIndex }))).flat();
return sum(targetActions.map(action => action.dps))
}))!;

const maxDtpsTargetActions = targets.map(target => target.getMeleeActions().concat(target.getSpellActions()).map(action => action.forTarget({ player: players[maxDpsIndex].unitIndex }))).flat();
const maxDtpsTargetActions = targets.map(target => target.getPlayerAndPetActions().map(action => action.forTarget({ player: players[maxDpsIndex].unitIndex }))).flat();
this.maxDtps = sum(maxDtpsTargetActions.map(action => action.dps));

return players.map(player => [player]);
Expand Down

0 comments on commit 7fd2165

Please sign in to comment.