From 2f8c6e4a8ef330e0b6adbb2a7dfed2c66320a6a4 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 8 Apr 2013 20:07:37 -0400 Subject: [PATCH] Move stat adjustments from stats class to d3class class --- libs/diabloclass.php | 63 +++++++++++++++++++++++++++++++++++ libs/diabloprogress_stats.php | 62 ---------------------------------- 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/libs/diabloclass.php b/libs/diabloclass.php index 59b91b1..ceb88d3 100644 --- a/libs/diabloclass.php +++ b/libs/diabloclass.php @@ -30,6 +30,15 @@ class DiabloClass { $this->stats = $stats; $this->type = $type; $this->class = $stats->class; + + $this->stats->stats['Gem Life'] = $this->calculateGemLife(); + $this->modifyExpBonus(); + + $this->stats->stats['All Elemental Damage'] = $this->elementalDamage(); + + $this->modifyDPSUnbuffed(); + $this->modifyEHP(); + $this->modifyHP(); } function hallScore() { @@ -88,4 +97,58 @@ class DiabloClass { function miscScore() { return 1; } + + protected + function isParagonMaxed() { + return $this->stats->getStat('Paragon Level') == 100; + } + + private + function elementalDamage() { + $totalElemental = 0; + foreach($this->stats as $stat => $value) { + if(preg_match('/\+DPS \(.*\)/', $stat) > 0) { + $totalElemental += $value; + } + } + + return ($totalElemental > 0) ? $totalElemental : 0; + } + + function calculateGemLife() { + if($this->isParagonMaxed()) return 0; + + switch($this->stats->getStat('Exp Bonus')) { + case .19: return .12; + case .21: return .14; + case .25: return .15; + case .27: return .16; + case .29: return .17; + case .31: return .18; + default: return 0; + } + } + + function modifyExpBonus() { + if($this->stats->getStat('Exp Bonus') >= .35) { + $this->stats->stats['Exp Bonus'] = $this->stats->getStat('Exp Bonus') - .35; + } + } + + function modifyDPSUnbuffed() { + $this->stats->stats['DPS Unbuffed'] = $this->stats->getStat('DPS Unbuffed') * + max(1, 1 + ($this->stats->getStat('+DPS Against Elites') / 2)); + } + + function modifyEHP() { + $this->stats->stats['EHP Unbuffed'] = $this->stats->getStat('EHP Unbuffed') * + (1 + $this->stats->getStat('Life Bonus') + $this->stats->getStat('Gem Life')) / + (1 + $this->stats->getStat('Life Bonus')); + } + + function modifyHP() { + $this->stats->stats['Life'] = $this->stats->getStat('Life') * + (1 + $this->stats->getStat('Life Bonus') + $this->stats->getStat('Gem Life')) / + (1 + $this->stats->getStat('Life Bonus')); + } } diff --git a/libs/diabloprogress_stats.php b/libs/diabloprogress_stats.php index 0c4479c..98bab01 100644 --- a/libs/diabloprogress_stats.php +++ b/libs/diabloprogress_stats.php @@ -6,11 +6,6 @@ class DiabloProgressStats extends Stats { $this->parseStats(); } - protected - function isParagonMaxed() { - return $this->getStat('Paragon Level') == 100; - } - private function findClass() { preg_match('{(.*?)}', $this->html, $class); @@ -29,62 +24,5 @@ class DiabloProgressStats extends Stats { } $this->stats[$attributes[1][$i]] = $attributes[2][$i]; } - - $this->stats['Gem Life'] = $this->calculateGemLife(); - $this->modifyExpBonus(); - - $this->stats['All Elemental Damage'] = $this->elementalDamage(); - - $this->modifyDPSUnbuffed(); - $this->modifyEHP(); - $this->modifyHP(); - } - - function elementalDamage() { - $totalElemental = 0; - foreach($this->stats as $stat => $value) { - if(preg_match('/\+DPS \(.*\)/', $stat) > 0) { - $totalElemental += $value; - } - } - - return ($totalElemental > 0) ? $totalElemental : 0; - } - - function calculateGemLife() { - if($this->isParagonMaxed()) return 0; - - switch($this->getStat('Exp Bonus')) { - case .19: return .12; - case .21: return .14; - case .25: return .15; - case .27: return .16; - case .29: return .17; - case .31: return .18; - default: return 0; - } - } - - function modifyExpBonus() { - if($this->getStat('Exp Bonus') >= .35) { - $this->stats['Exp Bonus'] = $this->getStat('Exp Bonus') - .35; - } - } - - function modifyDPSUnbuffed() { - $this->stats['DPS Unbuffed'] = $this->getStat('DPS Unbuffed') * - max(1, 1 + ($this->getStat('+DPS Against Elites') / 2)); - } - - function modifyEHP() { - $this->stats['EHP Unbuffed'] = $this->getStat('EHP Unbuffed') * - (1 + $this->getStat('Life Bonus') + $this->getStat('Gem Life')) / - (1 + $this->getStat('Life Bonus')); - } - - function modifyHP() { - $this->stats['Life'] = $this->getStat('Life') * - (1 + $this->getStat('Life Bonus') + $this->getStat('Gem Life')) / - (1 + $this->getStat('Life Bonus')); } } \ No newline at end of file