diff --git a/d3hog_driver.php b/d3hog_driver.php index 4103e9d..6b50a03 100644 --- a/d3hog_driver.php +++ b/d3hog_driver.php @@ -16,21 +16,63 @@ if($_POST['submit']) { die('Bad provider. Either your provider could not be detected or we do not support your provider at this time.'); } - $character = DiabloClassFactory::createClassObject($stats->class, $stats); + $pve = DiabloClassFactory::createClassObject($stats->class, $stats, 'pve'); + $pvp = DiabloClassFactory::createClassObject($stats->class, $stats, 'pvp'); - if($character === FALSE) { + if($pve === FALSE) { + die('Bad class. Either your class could not be detected or we do not support your class at this time.'); + } + if($pvp === FALSE) { die('Bad class. Either your class could not be detected or we do not support your class at this time.'); } ?>
-Hall Score: hallScore(), 2, '.', ','); ?>

- -DPS Score: DPSScore(), 2, '.', ','); ?>
-EHP Score: EHPScore(), 2, '.', ','); ?>
-Sustain Score: sustainScore(), 2, '.', ','); ?>
-Move Score: moveScore(), 2, '.', ','); ?>
-Paragon Score: paragonScore(), 2, '.', ','); ?>
-Misc Score: miscScore(), 2, '.', ','); ?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PvEPvP
Hall ScorehallScore(), 2, '.', ','); ?>hallScore(), 2, '.', ','); ?>
DPS ScoreDPSScore(), 2, '.', ','); ?>DPSScore(), 2, '.', ','); ?>
EHP ScoreEHPScore(), 2, '.', ','); ?>EHPScore(), 2, '.', ','); ?>
Sustain ScoresustainScore(), 2, '.', ','); ?>sustainScore(), 2, '.', ','); ?>
Move ScoremoveScore(), 2, '.', ','); ?>moveScore(), 2, '.', ','); ?>
Paragon ScoreparagonScore(), 2, '.', ','); ?>0
Misc ScoremiscScore(), 2, '.', ','); ?>miscScore(), 2, '.', ','); ?>

class = $stats->class; - - parent::__construct($stats); + function __construct($stats, $type) { + parent::__construct($stats, $type); } + + function EHPScore() { + $ehp = $this->calculateEHP(); + + if($this->type == 'pvp') { + return $ehp / 10000; + } + + if($ehp < 1000000) { + return $ehp / 10000; + } elseif(1000000 <= $ehp && $ehp <= 2000000) { + return 100 + ($ehp - 1000000) / 20000; + } elseif(2000000 <= $ehp && $ehp <= 5000000) { + return 150 + ($ehp - 2000000) / 40000; + } elseif($ehp >= 5000000) { + return 225 + ($ehp - 5000000) / 100000; + } + } + + protected + function calculateEHP() { + if($this->type == 'pvp') { + $ar_mod = 300;$armor_mod = 3000;$inherent_red = .35;$incoming_attack = 250000; + $net_mod = .50; // no idea what this is for + } else { + $ar_mod = 315;$armor_mod = 3150;$inherent_red = .30;$incoming_attack = 100000; + $net_mod = .75; // no idea what this is for + } + + $block_amount = 4206; + $ar_red = $this->stats->getStat('Resistance') / + ($this->stats->getStat('Resistance') + $ar_mod); + $armor_red = $this->stats->getStat('Armor') / + ($this->stats->getStat('Armor') + $armor_mod); + + $total_red = (1 - $ar_red) * (1 - $armor_red) * (1 - $inherent_red); + $raw_ehp = $this->stats->getStat('Life') / $total_red; + + $net = $incoming_attack * $total_red; + + $after_block = $net * (1 - $this->stats->getStat('Block Chance')) + ($net - $block_amount) + * $this->stats->getStat('Block Chance'); + + $new_mit = $after_block / $incoming_attack; + + $raw_no_dodge = $this->stats->getStat('Life') / $new_mit; + + if($this->type == 'pvp') { + $net_no_dodge = ($raw_no_dodge - $raw_ehp) * .75 + $raw_ehp; + } else { + $net_no_dodge = $raw_no_dodge; + } + + $raw_ehp_dodge = $raw_no_dodge / (1 - $this->stats->getStat('Dodge Chance')); + $net_ehp_dodge = ($raw_ehp_dodge - $net_no_dodge) * $net_mod + $net_no_dodge; + + $final_ehp = $net_ehp_dodge * (1 + ($this->stats->getStat('Melee Damage Reduction') + + $this->stats->getStat('Missile Damage Reduction')) / 2); + + $this->stats->stats['EHP Unbuffed'] = $final_ehp; + return $final_ehp; + } } \ No newline at end of file diff --git a/libs/demonhunter.php b/libs/demonhunter.php index 5d67d25..0423bf1 100644 --- a/libs/demonhunter.php +++ b/libs/demonhunter.php @@ -1,13 +1,15 @@ class = $stats->class; - - parent::__construct($stats); + function __construct($stats, $type) { + parent::__construct($stats, $type); } - + function EHPScore() { - $ehp = $this->stats->getStat('EHP Unbuffed'); + $ehp = $this->calculateEHP(); + + if($this->type == 'pvp') { + return $ehp / 10000; + } if($ehp <= 500000) { return $ehp / 10000; @@ -21,15 +23,39 @@ class DemonHunter extends DiabloClass { } function sustainScore() { - $effectiveLs = $this->stats->getStat('DPS Unbuffed') * - $this->stats->getStat('Life Steal') * .2; - $mitigation = $this->stats->getStat('EHP Unbuffed') / $this->stats->getStat('Life'); + $ehp = $this->calculateEHP(); + if($this->stats->getStat('Attacks per Second') > 2) { + $lsCoefficient = .1; + } else { + $lsCoefficient = .2; + } - return 1 + $mitigation * ($this->stats->getStat('Life on Hit') * - ($this->stats->getStat('Attacks per Second') + 1) / 2 + + $effectiveLs = $this->stats->getStat('DPS Unbuffed') * + $this->stats->getStat('Life Steal') * $lsCoefficient; + $mitigation = $ehp / $this->stats->getStat('Life'); + $loh = $this->stats->getStat('Life on Hit'); + + if($this->type == 'pvp') { + $ls = 0; + $loh = 0; + } + + + $rawSustainScore = 1 + $mitigation * ($loh * + (1 + ($this->stats->getStat('Attacks per Second') - 1) / 2) + $this->stats->getStat('Life per Second') + $effectiveLs) / ($this->stats->getStat('Life') * $this->EHPScore() * 10000 / - $this->stats->getStat('EHP Unbuffed')); + $ehp); + + if($rawSustainScore <= 1.5) { + return $rawSustainScore; + } elseif(1.5 < $rawSustainScore && $rawSustainScore <= 2) { + return 1.5 + ($rawSustainScore - 1.5) / 2; + } elseif(2 < $rawSustainScore && $rawSustainScore <= 3) { + return 1.75 + ($rawSustainScore - 2) / 4; + } else { + return 2 + ($rawSustainScore - 3) / 10; + } } function miscScore() { @@ -37,4 +63,48 @@ class DemonHunter extends DiabloClass { $this->stats->getStat('+Hatred Regenerated per Second') * 2 + $this->stats->getStat('+Discipline Regenerated per Second') * 15) / 100; } + + protected + function calculateEHP() { + if($this->type == 'pvp') { + $ar_mod = 300;$armor_mod = 3000;$inherent_red = 0.30;$incoming_attack = 250000; + $net_mod = .50; // no idea what this is for + } else { + $ar_mod = 315;$armor_mod = 3150;$inherent_red = 0.00;$incoming_attack = 100000; + $net_mod = .75; // no idea what this is for + } + + $block_amount = 4206; + $ar_red = $this->stats->getStat('Resistance') / + ($this->stats->getStat('Resistance') + $ar_mod); + $armor_red = $this->stats->getStat('Armor') / + ($this->stats->getStat('Armor') + $armor_mod); + + $total_red = (1 - $ar_red) * (1 - $armor_red) * (1 - $inherent_red); + $raw_ehp = $this->stats->getStat('Life') / $total_red; + + $net = $incoming_attack * $total_red; + + $after_block = $net * (1 - $this->stats->getStat('Block Chance')) + ($net - $block_amount) + * $this->stats->getStat('Block Chance'); + + $new_mit = $after_block / $incoming_attack; + + $raw_no_dodge = $this->stats->getStat('Life') / $new_mit; + + if($this->type == 'pvp') { + $net_no_dodge = ($raw_no_dodge - $raw_ehp) * .75 + $raw_ehp; + } else { + $net_no_dodge = $raw_no_dodge; + } + + $raw_ehp_dodge = $raw_no_dodge / (1 - $this->stats->getStat('Dodge Chance')); + $net_ehp_dodge = ($raw_ehp_dodge - $net_no_dodge) * $net_mod + $net_no_dodge; + + $final_ehp = $net_ehp_dodge * (1 + ($this->stats->getStat('Melee Damage Reduction') + + $this->stats->getStat('Missile Damage Reduction')) / 2); + + $this->stats->stats['EHP Unbuffed'] = $final_ehp; + return $final_ehp; + } } \ No newline at end of file diff --git a/libs/diabloclass.php b/libs/diabloclass.php index c08b2ac..f745c3e 100644 --- a/libs/diabloclass.php +++ b/libs/diabloclass.php @@ -1,13 +1,13 @@ stats = $stats; + $this->type = $type; + $this->class = $stats->class; + + $this->modifyExpBonus(); + + $this->stats->stats['All Elemental Damage'] = $this->elementalDamage(); + + $this->modifyDPSUnbuffed(); + $this->calculateEHP(); } function hallScore() { - return $this->DPSScore() * $this->EHPScore() * $this->sustainScore() - * $this->moveScore() * $this->paragonScore() * $this->miscScore(); + $hallScore = $this->DPSScore() * $this->EHPScore() * $this->sustainScore() + * $this->moveScore() * $this->miscScore(); + if($this->type == 'pve') { + $hallScore *= $this->paragonScore(); + } + return $hallScore; } function DPSScore() { @@ -39,29 +53,26 @@ class DiabloClass { } function EHPScore() { - $ehp = $this->stats->getStat('EHP Unbuffed'); - - if($ehp < 1000000) { - return $ehp / 10000; - } elseif(1000000 <= $ehp && $ehp <= 2000000) { - return 100 + ($ehp - 1000000) / 20000; - } elseif(2000000 <= $ehp && $ehp <= 5000000) { - return 150 + ($ehp - 2000000) / 40000; - } elseif($ehp >= 5000000) { - return 225 + ($ehp - 5000000) / 100000; - } + return 0; } function sustainScore() { + $ehp = $this->calculateEHP(); $effectiveLS = $this->stats->getStat('DPS Unbuffed') * $this->stats->getStat('Life Steal') * .5; - $mitigation = $this->stats->getStat('EHP Unbuffed') / $this->stats->getStat('Life'); + $mitigation = $ehp / $this->stats->getStat('Life'); + $loh = $this->stats->getStat('Life on Hit'); - $rawSustainScore = 1 + $mitigation * ($this->stats->getStat('Life on Hit') * + if($this->type == 'pvp') { + $effectiveLS = 0; + $loh = 0; + } + + $rawSustainScore = 1 + $mitigation * ($loh * (1 + ($this->stats->getStat('Attacks per Second') - 1) / 2) + $effectiveLS + $this->stats->getStat('Life per Second')) / ($this->stats->getStat('Life') * $this->EHPScore() * 10000 / - $this->stats->getStat('EHP Unbuffed')); + $ehp); if($rawSustainScore <= 1.5) { return $rawSustainScore; @@ -85,4 +96,51 @@ class DiabloClass { function miscScore() { return 1; } + + protected + function isParagonMaxed() { + return $this->stats->getStat('Paragon Level') == 100; + } + + function modifyDPSUnbuffed() { + if($this->type == 'pvp') { + $eliteDivisor = 1; + } else { + $eliteDivisor = 2; + } + $this->stats->stats['DPS Unbuffed'] = $this->stats->getStat('DPS Unbuffed') * + max(1, 1 + ($this->stats->getStat('+DPS Against Elites') / $eliteDivisor)); + } + + 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() || $this->type == 'pvp') 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; + } + } } 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