Merge branch 'bugfix-remove_elemental'

This commit is contained in:
Andrew Tomaka 2012-12-06 13:41:13 -05:00
commit 14bb00bfd1
2 changed files with 5 additions and 13 deletions

View file

@ -4,7 +4,6 @@ include_once(__DIR__ . '/libs/dpclass.php');
if($_POST['submit']) { if($_POST['submit']) {
$diabloProgressUrl = trim($_POST['url']); $diabloProgressUrl = trim($_POST['url']);
$elementalOnWeapon = isset($_POST['elemental']['elemental']) ? true : false;
if(preg_match('{^http://www.diabloprogress.com/hero/.*\-[\d]+/.*/[\d]+$}', $diabloProgressUrl) != 1) { if(preg_match('{^http://www.diabloprogress.com/hero/.*\-[\d]+/.*/[\d]+$}', $diabloProgressUrl) != 1) {
die('Bad URL. Please enter the entire diablo progress URL.<br/><br/>Example: http://www.diabloprogress.com/hero/celanian-1548/HsuMing/21706367'); die('Bad URL. Please enter the entire diablo progress URL.<br/><br/>Example: http://www.diabloprogress.com/hero/celanian-1548/HsuMing/21706367');
} }
@ -17,7 +16,7 @@ if($_POST['submit']) {
$contents = curl_exec($curl); $contents = curl_exec($curl);
curl_close($curl); curl_close($curl);
$character = DPClassFactory::createClassObject($contents, $elementalOnWeapon); $character = DPClassFactory::createClassObject($contents);
if($character === FALSE) { if($character === FALSE) {
die('Bad class. Either your class could not be detected or we do not support your class at this time.'); die('Bad class. Either your class could not be detected or we do not support your class at this time.');
@ -38,6 +37,5 @@ Misc Score: <?php echo number_format($character->miscScore(), 2, '.', ','); ?><b
?> ?>
<form method="POST"> <form method="POST">
D3 Progress URL: <input type="text" name="url" style="width:500px;" value="<?php echo $diabloProgressUrl ?>" /><br /> D3 Progress URL: <input type="text" name="url" style="width:500px;" value="<?php echo $diabloProgressUrl ?>" /><br />
Elemental Damage on Weapon: <input type="checkbox" name="elemental" value="elemental" <?php echo $elementalOnWeapon ? 'checked="checked"' : '' ?> /><br/>
<input type="submit" name="submit" /> <input type="submit" name="submit" />
</form> </form>

View file

@ -1,16 +1,16 @@
<?php <?php
class DPClassFactory { class DPClassFactory {
function createClassObject($characterPage, $elementalOnWeapon) { function createClassObject($characterPage) {
$class = DPClassFactory::findClass($characterPage); $class = DPClassFactory::findClass($characterPage);
include_once(__DIR__ . "/$class.php"); include_once(__DIR__ . "/$class.php");
switch($class) { switch($class) {
case 'barbarian': case 'barbarian':
return new Barbarian($characterPage, $elementalOnWeapon); return new Barbarian($characterPage);
case 'demonhunter': case 'demonhunter':
return new DemonHunter($characterPage, $elementalOnWeapon); return new DemonHunter($characterPage);
default: default:
return false; return false;
} }
@ -30,11 +30,10 @@ class DPClass {
var $stats = array(); var $stats = array();
var $items = array(); var $items = array();
function __construct($characterPage, $elementalOnWeapon) { function __construct($characterPage) {
$this->dpHTML = $characterPage; $this->dpHTML = $characterPage;
$this->class = get_class($this); $this->class = get_class($this);
$this->elementalOnWeapon = $elementalOnWeapon;
$this->parseStats(); $this->parseStats();
} }
@ -136,10 +135,6 @@ class DPClass {
} }
} }
if($this->elementalOnWeapon && $totalElemental != 1) {
$totalElemental *= .5;
}
return ($totalElemental > 0) ? $totalElemental : 0; return ($totalElemental > 0) ? $totalElemental : 0;
} }
@ -165,7 +160,6 @@ class DPClass {
function modifyDPSUnbuffed() { function modifyDPSUnbuffed() {
$this->stats['DPS Unbuffed'] = $this->getStat('DPS Unbuffed') * $this->stats['DPS Unbuffed'] = $this->getStat('DPS Unbuffed') *
(1 + $this->getStat('All Elemental Damage')) *
max(1, 1 + ($this->getStat('+DPS Against Elites') / 2)); max(1, 1 + ($this->getStat('+DPS Against Elites') / 2));
} }