From 4dfe41f91edc6a412fec99e1d06b3850291da197 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sat, 3 Nov 2012 22:45:03 -0400 Subject: [PATCH] Initial commit --- README.md | 35 +++++++++++++++ d3hog_driver.php | 41 ++++++++++++++++++ libs/barbarian.php | 16 +++++++ libs/dpclass.php | 106 +++++++++++++++++++++++++++++++++++++++++++++ libs/wizard.php | 19 ++++++++ 5 files changed, 217 insertions(+) create mode 100644 README.md create mode 100644 d3hog_driver.php create mode 100644 libs/barbarian.php create mode 100644 libs/dpclass.php create mode 100644 libs/wizard.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..503ea3c --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +#Diablo 3 Hall of Glory + +Calculate a formula to determine a raw score used to rank Diablo 3 profiles. + +##Description + +Implement the formula described by Celanian in [a thread on the Diablo 3 +Barbarian forums] (http://us.battle.net/d3/en/forum/topic/7004690628) as a +simple web application. This is accomplished by accepting a [Diablo Progress] +(http://www.diabloprogress.com) URL and parsing the values calculated on the +side bar to determine an overall "Hall of Glory" score. + +##License + +The MIT License + +Copyright (c) 2012 Andrew Tomaka + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/d3hog_driver.php b/d3hog_driver.php new file mode 100644 index 0000000..b1eecde --- /dev/null +++ b/d3hog_driver.php @@ -0,0 +1,41 @@ +
Example: http://www.diabloprogress.com/hero/celanian-1548/HsuMing/21706367'); + } + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $diabloProgressUrl); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $contents = curl_exec($curl); + curl_close($curl); + + $character = DPClassFactory::createClassObject($contents); + + if($character === 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); ?>
+
+ +
+ D3 Progress URL:
+ +
\ No newline at end of file diff --git a/libs/barbarian.php b/libs/barbarian.php new file mode 100644 index 0000000..cc4d501 --- /dev/null +++ b/libs/barbarian.php @@ -0,0 +1,16 @@ +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; + } + } +} \ No newline at end of file diff --git a/libs/dpclass.php b/libs/dpclass.php new file mode 100644 index 0000000..13fa791 --- /dev/null +++ b/libs/dpclass.php @@ -0,0 +1,106 @@ +(.*?)}', $characterPage, $class); + + return strtolower($class[1]); + } +} + +class DPClass { + var $dpHTML; + var $class; + var $stats = array(); + var $items = array(); + + function __construct($characterPage) { + $this->dpHTML = $characterPage; + + $this->class = get_class($this); + + $this->parseStats(); + } + + function parseStats() { + preg_match_all('{
(.*?):<\/span> (.*?)<\/span><\/nobr><\/div>}', $this->dpHTML, $attributes); + + for($i = 0; $i < count($attributes[0]); $i++) { + $attributes[2][$i] = str_replace(',', '', $attributes[2][$i]); + if(preg_match('/%/', $attributes[2][$i]) > 0) { + $attributes[2][$i] = str_replace('%', '', $attributes[2][$i]); + $attributes[2][$i] /= 100; + } + $this->stats[$attributes[1][$i]] = $attributes[2][$i]; + } + + $this->stats['All Elemental Damage'] = $this->calculateElementalDamage(); + $this->stats['DPS Unbuffed'] = $this->calculateModifiedDPSUnbuffed(); + } + + function calculateElementalDamage() { + $totalElemental = 0; + foreach($this->stats as $stat => $value) { + if(preg_match('/\+DPS \(.*\)/', $stat) > 0) { + $totalElemental += $value; + } + + return ($totalElemental > 0) ? $totalElemental + 1 : 0; + } + } + + function calculateModifiedDPSUnbuffed() { + return $this->getStat('DPS Unbuffed') * max(1, $this->getStat('All Elemental Damage')) + * max(1, $this->getStat('+DPS Against Elites')); + } + + function hallScore() { + return $this->DPSScore() * $this->EHPScore() * $this->sustainScore() + * $this->moveScore() * $this->paragonScore() * $this->miscScore(); + } + + function DPSScore() { + return $this->getStat('DPS Unbuffed') / 1000; + } + + function EHPScore() {} + + function sustainScore() { + $effectiveLS = $this->getStat('DPS Unbuffed') * $this->getStat('Life Steal') * .2; + + return 1 + ($this->getStat('Life on Hit') + $this->getStat('Life per Second') + $effectiveLS) + * 10 / $this->getStat('Life'); + } + + function moveScore() { + return ($this->getStat('Movement Speed') > .25) ? 1.25 : 1 + $this->getStat('Movement Speed'); + } + + function paragonScore() { + return 1 + $this->stats['Paragon Level'] / 2 / 100; + } + + function miscScore() { + return 1 + ($this->getStat('Melee Damage Reduction') + $this->getStat('Missile Damage Reduction') + + $this->getStat('Exp Bonus')) / 2; + } + + function getStat($name) { + return (isset($this->stats[$name])) ? $this->stats[$name] : 0; + } +} diff --git a/libs/wizard.php b/libs/wizard.php new file mode 100644 index 0000000..dfbebe0 --- /dev/null +++ b/libs/wizard.php @@ -0,0 +1,19 @@ +getStat('EHP Unbuffed'); + + switch($ehp) { + case ($ehp < 250000): + return $ehp / 5000; + case ($ehp >= 250000 && $ehp < 450000): + return 50 + ($ehp - 250000) / 4000; + case ($ehp >= 450000 && $ehp < 600000): + return 100 + ($ehp - 450000) / 3000; + case ($ehp >= 600000 && $ehp < 1000000): + return 150 + ($ehp - 600000) / 8000; + case ($ehp >= 1000000): + return 200 + ($ehp - 1000000) / 25000; + } + } +}