d3hog/libs/dpclass.php
Andrew Tomaka eac6c34fa1 Limit XP Contribution
Experience bonuses are counted in the formula so that someone opting
to use a Ruby over an Amethyst in their helmet would not be penalized
too greatly.  However, with the addition of the Hellfire ring,
experience bonuses were giving Hellfire ring users a huge bonus.  By
limiting the experience bonus to 35%, the original intent is kept in
tact while preventing Hellfire abuse.
2012-11-07 21:57:41 -05:00

109 lines
3 KiB
PHP

<?php
class DPClassFactory {
function createClassObject($characterPage) {
$class = DPClassFactory::findClass($characterPage);
include_once(__DIR__ . "/$class.php");
switch($class) {
case 'barbarian':
return new Barbarian($characterPage);
case 'wizard':
return new Wizard($characterPage);
default:
return false;
}
}
function findClass($characterPage) {
preg_match('{<span class="diablo_.*?">(.*?)</span>}', $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('{<div class="char_attr"><nobr><span class="char_attr_name">(.*?):<\/span> <span class="char_attr_value">(.*?)<\/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->elementalDamage();
// $this->stats['DPS Unbuffed'] = $this->modifiedDPSUnbuffed();
}
function elementalDamage() {
$totalElemental = 0;
foreach($this->stats as $stat => $value) {
if(preg_match('/\+DPS \(.*\)/', $stat) > 0) {
$totalElemental += $value;
}
}
return ($totalElemental > 0) ? $totalElemental + 1 : 0;
}
function modifiedDPSUnbuffed() {
return $this->getStat('DPS Unbuffed') * max(1, 1 + ($this->getStat('All Elemental Damage') / 2))
* max(1, 1 + ($this->getStat('+DPS Against Elites') / 2));
}
function hallScore() {
return $this->DPSScore() * $this->EHPScore() * $this->sustainScore()
* $this->moveScore() * $this->paragonScore() * $this->miscScore();
}
function DPSScore() {
return $this->modifiedDPSUnbuffed() / 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() {
$bonusXP = $this->getStat('Exp Bonus');
if($bonusXP >= .35) $bonusXP -= .35;
return 1 + ($this->getStat('Melee Damage Reduction') + $this->getStat('Missile Damage Reduction')
+ $bonusXP) / 2;
}
function getStat($name) {
return (isset($this->stats[$name])) ? $this->stats[$name] : 0;
}
}