Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose BlockValueMultiplier pseudostat in the UI to fix stat display … #2172

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ enum PseudoStat {
PseudoStatMainHandDps = 0;
PseudoStatOffHandDps = 1;
PseudoStatRangedDps = 2;
PseudoStatBlockValueMultiplier = 3;
}

message UnitStats {
Expand Down
8 changes: 8 additions & 0 deletions sim/core/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ type Weapon struct {
SpellSchool SpellSchool
}

func (w Weapon) DPS() float64 {
if w.SwingSpeed == 0 {
return 0
} else {
return (w.BaseDamageMin + w.BaseDamageMax) / 2.0 / w.SwingSpeed
}
}

func (w Weapon) WithBonusDPS(bonusDps float64) Weapon {
newWeapon := w
bonusSwingDamage := bonusDps * w.SwingSpeed
Expand Down
7 changes: 6 additions & 1 deletion sim/core/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,12 @@ func (character *Character) doneIteration(sim *Simulation) {
}

func (character *Character) GetPseudoStatsProto() []float64 {
return nil
vals := make([]float64, stats.PseudoStatsLen)
vals[proto.PseudoStat_PseudoStatMainHandDps] = character.WeaponFromMainHand(0).DPS()
vals[proto.PseudoStat_PseudoStatOffHandDps] = character.WeaponFromOffHand(0).DPS()
vals[proto.PseudoStat_PseudoStatRangedDps] = character.WeaponFromRanged(0).DPS()
vals[proto.PseudoStat_PseudoStatBlockValueMultiplier] = character.PseudoStats.BlockValueMultiplier
return vals
}

func (character *Character) GetMetricsProto() *proto.UnitMetrics {
Expand Down
31 changes: 18 additions & 13 deletions ui/core/components/character_stats.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stat, Class } from '..//proto/common.js';
import { Stat, Class, PseudoStat } from '..//proto/common.js';
import { TristateEffect } from '..//proto/common.js'
import { getClassStatName, statOrder } from '..//proto_utils/names.js';
import { Stats } from '..//proto_utils/stats.js';
Expand Down Expand Up @@ -87,13 +87,13 @@ export class CharacterStats extends Component {
this.stats.forEach((stat, idx) => {
let fragment = document.createElement('fragment');
fragment.innerHTML = `
<a href="javascript:void(0)" class="stat-value-link" role="button" data-bs-toggle="tooltip" data-bs-html="true">${this.statDisplayString(finalStats, stat)}</a>
<a href="javascript:void(0)" class="stat-value-link" role="button" data-bs-toggle="tooltip" data-bs-html="true">${this.statDisplayString(finalStats, finalStats, stat)}</a>
`
let valueElem = fragment.children[0] as HTMLElement;
this.valueElems[idx].querySelector('.stat-value-link')?.remove()
this.valueElems[idx].prepend(valueElem);

let bonusStatValue = player.getBonusStats().getStat(stat);
let bonusStatValue = bonusStats.getStat(stat);

if (bonusStatValue == 0) {
valueElem.classList.remove('text-success', 'text-danger');
Expand All @@ -109,48 +109,53 @@ export class CharacterStats extends Component {
valueElem.setAttribute('data-bs-title', `
<div class="character-stats-tooltip-row">
<span>Base:</span>
<span>${this.statDisplayString(baseDelta, stat)}</span>
<span>${this.statDisplayString(baseStats, baseDelta, stat)}</span>
</div>
<div class="character-stats-tooltip-row">
<span>Gear:</span>
<span>${this.statDisplayString(gearDelta, stat)}</span>
<span>${this.statDisplayString(gearStats, gearDelta, stat)}</span>
</div>
<div class="character-stats-tooltip-row">
<span>Talents:</span>
<span>${this.statDisplayString(talentsDelta, stat)}</span>
<span>${this.statDisplayString(talentsStats, talentsDelta, stat)}</span>
</div>
<div class="character-stats-tooltip-row">
<span>Buffs:</span>
<span>${this.statDisplayString(buffsDelta, stat)}</span>
<span>${this.statDisplayString(buffsStats, buffsDelta, stat)}</span>
</div>
<div class="character-stats-tooltip-row">
<span>Consumes:</span>
<span>${this.statDisplayString(consumesDelta, stat)}</span>
<span>${this.statDisplayString(consumesStats, consumesDelta, stat)}</span>
</div>
${debuffStats.getStat(stat) == 0 ? '' : `
<div class="character-stats-tooltip-row">
<span>Debuffs:</span>
<span>${this.statDisplayString(debuffStats, stat)}</span>
<span>${this.statDisplayString(debuffStats, debuffStats, stat)}</span>
</div>
`}
${bonusStatValue == 0 ? '' : `
<div class="character-stats-tooltip-row">
<span>Bonus:</span>
<span>${this.statDisplayString(this.player.getBonusStats(), stat)}</span>
<span>${this.statDisplayString(bonusStats, bonusStats, stat)}</span>
</div>
`}
<div class="character-stats-tooltip-row">
<span>Total:</span>
<span>${this.statDisplayString(finalStats, stat)}</span>
<span>${this.statDisplayString(finalStats, finalStats, stat)}</span>
</div>
`);

Tooltip.getOrCreateInstance(valueElem);
});
}

private statDisplayString(stats: Stats, stat: Stat): string {
const rawValue = stats.getStat(stat);
private statDisplayString(stats: Stats, deltaStats: Stats, stat: Stat): string {
let rawValue = deltaStats.getStat(stat);

if (stat == Stat.StatBlockValue) {
rawValue *= stats.getPseudoStat(PseudoStat.PseudoStatBlockValueMultiplier) || 1;
}

let displayStr = String(Math.round(rawValue));

if (stat == Stat.StatMeleeHit) {
Expand Down
2 changes: 0 additions & 2 deletions ui/core/components/exporters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ export class Individual80UEPExporter<SpecType extends Spec> extends Exporter {
}
static pseudoStatNames: Partial<Record<PseudoStat, string>> = {
[PseudoStat.PseudoStatMainHandDps]: 'dps',
[PseudoStat.PseudoStatOffHandDps]: '',
[PseudoStat.PseudoStatRangedDps]: 'rangedDps',
}
}
Expand Down Expand Up @@ -270,7 +269,6 @@ export class IndividualPawnEPExporter<SpecType extends Spec> extends Exporter {
}
static pseudoStatNames: Partial<Record<PseudoStat, string>> = {
[PseudoStat.PseudoStatMainHandDps]: 'MeleeDps',
[PseudoStat.PseudoStatOffHandDps]: '',
[PseudoStat.PseudoStatRangedDps]: 'RangedDps',
}
}
15 changes: 13 additions & 2 deletions ui/core/components/stat_weights_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ class EpWeightsMenu extends Popup {
this.tableBody.innerHTML = '';
this.tableBody.appendChild(this.tableHeader);

const allUnitStats = UnitStat.getAll();
allUnitStats.forEach(stat => {
EpWeightsMenu.epUnitStats.forEach(stat => {
const row = this.makeTableRow(stat, iterations, result);
if ((stat.isStat() && !this.epStats.includes(stat.getStat())) || (stat.isPseudoStat() && !this.epPseudoStats.includes(stat.getPseudoStat()))) {
row.classList.add('non-ep-stat');
Expand Down Expand Up @@ -538,6 +537,18 @@ class EpWeightsMenu extends Popup {
bestGemEP: bestGemEP,
};
}

private static epUnitStats: Array<UnitStat> = UnitStat.getAll().filter(stat => {
if (stat.isStat()) {
return true;
} else {
return [
PseudoStat.PseudoStatMainHandDps,
PseudoStat.PseudoStatOffHandDps,
PseudoStat.PseudoStatRangedDps,
].includes(stat.getPseudoStat());
}
});
}

interface BestGemsResult {
Expand Down
2 changes: 2 additions & 0 deletions ui/core/proto_utils/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ export const pseudoStatOrder: Array<PseudoStat> = [
PseudoStat.PseudoStatMainHandDps,
PseudoStat.PseudoStatOffHandDps,
PseudoStat.PseudoStatRangedDps,
PseudoStat.PseudoStatBlockValueMultiplier,
];
export const pseudoStatNames: Record<PseudoStat, string> = {
[PseudoStat.PseudoStatMainHandDps]: 'Main Hand DPS',
[PseudoStat.PseudoStatOffHandDps]: 'Off Hand DPS',
[PseudoStat.PseudoStatRangedDps]: 'Ranged DPS',
[PseudoStat.PseudoStatBlockValueMultiplier]: 'Block Value Multiplier',
};

export function getClassStatName(stat: Stat, playerClass: Class): string {
Expand Down