From f2faa1ce41e39feab8f4912f1dc342bea3643da2 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 26 Nov 2012 02:25:42 -0500 Subject: [PATCH 1/2] Update form with new control --- d3hog_driver.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/d3hog_driver.php b/d3hog_driver.php index 8e01e67..ddb76a5 100644 --- a/d3hog_driver.php +++ b/d3hog_driver.php @@ -6,6 +6,7 @@ include_once(__DIR__ . '/libs/dpclass.php'); if($_POST['submit']) { $diabloProgressUrl = trim($_POST['url']); + $elementalOnWeapon = isset($_POST['elemental']['elemental']) ? true : false; if(preg_match('{^http://www.diabloprogress.com/hero/[\w]+\-[\d]+/[\w]+/[\d]+$}', $diabloProgressUrl) != 1) { die('Bad URL. Please enter the entire diablo progress URL.

Example: http://www.diabloprogress.com/hero/celanian-1548/HsuMing/21706367'); } @@ -38,5 +39,6 @@ Paragon Score: paragonScore(), 2, '.', ',') ?>
D3 Progress URL:
+ Elemental Damage on Weapon: />
\ No newline at end of file From 371ff473468a72f22bb33392d8ed7f3836a42104 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 26 Nov 2012 03:07:05 -0500 Subject: [PATCH 2/2] Process elemental damage on weapon --- d3hog_driver.php | 2 +- libs/dpclass.php | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/d3hog_driver.php b/d3hog_driver.php index ddb76a5..01a30de 100644 --- a/d3hog_driver.php +++ b/d3hog_driver.php @@ -19,7 +19,7 @@ if($_POST['submit']) { $contents = curl_exec($curl); curl_close($curl); - $character = DPClassFactory::createClassObject($contents); + $character = DPClassFactory::createClassObject($contents, $elementalOnWeapon); if($character === FALSE) { die('Bad class. Either your class could not be detected or we do not support your class at this time.'); diff --git a/libs/dpclass.php b/libs/dpclass.php index a8208af..8e084f5 100644 --- a/libs/dpclass.php +++ b/libs/dpclass.php @@ -1,16 +1,16 @@ dpHTML = $characterPage; $this->class = get_class($this); + $this->elementalOnWeapon = $elementalOnWeapon; $this->parseStats(); } @@ -61,14 +62,18 @@ class DPClass { } function elementalDamage() { - $totalElemental = 0; + $totalElemental = 1; foreach($this->stats as $stat => $value) { if(preg_match('/\+DPS \(.*\)/', $stat) > 0) { $totalElemental += $value; } } - return ($totalElemental > 0) ? $totalElemental + 1 : 0; + if($this->elementalOnWeapon && $totalElemental != 1) { + $totalElemental *= .5; + } + + return ($totalElemental > 0) ? $totalElemental : 0; } function calculateGemLife() { @@ -93,7 +98,7 @@ class DPClass { function modifyDPSUnbuffed() { $this->stats['DPS Unbuffed'] = $this->getStat('DPS Unbuffed') * - max(1, 1 + ($this->getStat('All Elemental Damage') / 2)) * + $this->getStat('All Elemental Damage') * max(1, 1 + ($this->getStat('+DPS Against Elites') / 2)); }