MediaWiki:Gadget-hero-comparison.js: Difference between revisionsGive feedback
Testing fix for dps |
Brought back dps calculations for warden while also accounting for heroes with spinup. |
||
| Line 59: | Line 59: | ||
function calculateStat(cell, spiritPower, powerIncreases) { | function calculateStat(cell, spiritPower, powerIncreases) { | ||
const statName = cell.dataset.statName; | const statName = cell.dataset.statName; | ||
// --- MULTIPLICATIVE STATS (DPS & SustainedDPS) --- | |||
// Dynamically compute based on the modified values of sibling cells in the same row | |||
if (statName === 'DPS' || statName === 'SustainedDPS') { | |||
const row = cell.closest('tr'); | |||
const dmg = calculateLinearStat(row.querySelector('td[data-stat-name="BulletDamage"]'), spiritPower, powerIncreases); | |||
const rpsCell = row.querySelector('td[data-stat-name="RoundsPerSecond"]'); | |||
const maxSpinCell = row.querySelector('td[data-stat-name="RoundsPerSecondAtMaxSpin"]'); | |||
// Use max spin RPS for spin-up weapons like McGinnis, otherwise use scaled RPS | |||
const rps = (maxSpinCell && parseFloat(maxSpinCell.dataset.base) > 0) | |||
? parseFloat(maxSpinCell.dataset.base) | |||
: calculateLinearStat(rpsCell, spiritPower, powerIncreases); | |||
const bpsCell = row.querySelector('td[data-stat-name="BulletsPerShot"]'); | |||
const hitOnce = cell.dataset.hitOnce === 'true'; | |||
const bps = hitOnce ? 1 : (bpsCell && bpsCell.dataset.base ? calculateLinearStat(bpsCell, spiritPower, powerIncreases) : 1); | |||
if (statName === 'DPS') { | |||
return roundToSigFigs(dmg * rps * Math.max(1, bps), 3); | |||
} else if (statName === 'SustainedDPS') { | |||
const clip = calculateLinearStat(row.querySelector('td[data-stat-name="ClipSize"]'), spiritPower, powerIncreases); | |||
const reload = calculateLinearStat(row.querySelector('td[data-stat-name="ReloadTime"]'), spiritPower, powerIncreases); | |||
if (rps === 0 || clip === 0) return 0; | |||
const sustained = (clip * dmg * Math.max(1, bps)) / ((clip / rps) + reload); | |||
return roundToSigFigs(sustained, 3); | |||
} | |||
} | |||
// --- LINEAR STATS (Everything Else) --- | // --- LINEAR STATS (Everything Else) --- | ||