Scoped methods

This commit is contained in:
Andrew Tomaka 2012-11-26 03:18:24 -05:00
parent bbf58e4d31
commit 7cab64e704

View file

@ -39,85 +39,6 @@ class DPClass {
$this->parseStats(); $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['Gem Life'] = $this->calculateGemLife();
$this->modifyExpBonus();
$this->stats['All Elemental Damage'] = $this->elementalDamage();
$this->modifyDPSUnbuffed();
$this->modifyEHP();
$this->modifyHP();
}
function elementalDamage() {
$totalElemental = 1;
foreach($this->stats as $stat => $value) {
if(preg_match('/\+DPS \(.*\)/', $stat) > 0) {
$totalElemental += $value;
}
}
if($this->elementalOnWeapon && $totalElemental != 1) {
$totalElemental *= .5;
}
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') *
$this->getStat('All Elemental Damage') *
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'));
}
function isParagonMaxed() {
return $this->getStat('Paragon Level') == 100;
}
function hallScore() { function hallScore() {
return $this->DPSScore() * $this->EHPScore() * $this->sustainScore() return $this->DPSScore() * $this->EHPScore() * $this->sustainScore()
* $this->moveScore() * $this->paragonScore(); * $this->moveScore() * $this->paragonScore();
@ -171,7 +92,88 @@ class DPClass {
return 1 + $this->stats['Paragon Level'] / 2 / 100; return 1 + $this->stats['Paragon Level'] / 2 / 100;
} }
function getStat($name) { protected
return (isset($this->stats[$name])) ? $this->stats[$name] : 0; function isParagonMaxed() {
} return $this->getStat('Paragon Level') == 100;
}
function getStat($name) {
return (isset($this->stats[$name])) ? $this->stats[$name] : 0;
}
private
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['Gem Life'] = $this->calculateGemLife();
$this->modifyExpBonus();
$this->stats['All Elemental Damage'] = $this->elementalDamage();
$this->modifyDPSUnbuffed();
$this->modifyEHP();
$this->modifyHP();
}
function elementalDamage() {
$totalElemental = 1;
foreach($this->stats as $stat => $value) {
if(preg_match('/\+DPS \(.*\)/', $stat) > 0) {
$totalElemental += $value;
}
}
if($this->elementalOnWeapon && $totalElemental != 1) {
$totalElemental *= .5;
}
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') *
$this->getStat('All Elemental Damage') *
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'));
}
} }