function score_stats($stats,$slot)
{
	// because derived stats are processed before calculating the score, 
	// the base stats weighting from which they are derived will need to be adjusted to compensate
	$score = $stats["intelligence"][0] * (($_POST['spellpowerweight']/2+$_POST['spellcritweight'])/2);
	$score += $stats["wisdom"][0]  *  (($_POST['spellpowerweight']/2)/2);

	// spellcrit is affected by soft/hardcaps, which is checked after applying buffs and talents
	$stats = talents_calculate($stats);
	$stats = buffs_calculate($stats);
	$stats = stats_derive($stats);
	$stats = talents_calculate_derived($stats);
	$stats = buffs_calculate_derived($stats);
	// if crit is over the softcap, store the surplus and score that using the regular weight multiplied by the softcap modifier
	if($stats["spellcrit"][0] > $stats["spellcrit"][6]) {
		$surplus = $stats["spellcrit"][0] - $stats["spellcrit"][6]; 
		$score += $stats["spellcrit"][6]  * $_POST['spellcritweight'];
		$score += $surplus * ($_POST['spellcritweight'] * $stats["spellcrit"][7]);	
	}
	else
	{	
		$score += $stats["spellcrit"][0]  * $_POST['spellcritweight'];
	}
	// put stats back in their unmodified state
	$stats = modifications_undo($stats);

	// and finally calculate the score from dps if a weapon is being checked
	if($slot == "offhand")
		$score += $stats["dps"][0]  * $_POST['ohdpsweight'];
	else if($slot == "mainhand")
		$score += $stats["dps"][0]  * $_POST['mhdpsweight'];
	else if($slot == "ranged")
		$score += $stats["dps"][0]  * $_POST['rngdpsweight'];
	return $score;
}
Example #2
0
function score($stats,$slot)
{
	// perform scoring of stats without thresholds according to implementation in $class_settings.php
	// since some derived stats are not thresholded, add them so they can be scored as well
	$stats = stats_derive($stats);
	$score = score_stats($stats,$slot);
	$stats = stats_derive_remove($stats);

	// perform scoring of stats with thresholds
	foreach($stats as $stat) {
              if($stat[5]) // if stat can have threshold
		{
			$target = $_POST[$stat[1].'target'];

			// update stats with new item
			$stats = talents_calculate($stats);
			$stats = buffs_calculate($stats);
			// derived stats disabled for now, since this causes some scores to be higher then they should
			//$stats = stats_derive($stats);
			$stats = talents_calculate_derived($stats);
			$stats = buffs_calculate_derived($stats);

			if($target>0) // if a threshold has been set in browser
			{
				if($stats[$stat[1]][0]>$target) { // if stat goes over the set threshold
					$surplus = $stats[$stat[1]][0]-$target;
					$score += $target * $_POST[$stat[1].'weight'];
					$score += $surplus * $_POST[$stat[1].'aboveweight'];
				}
				else // stat is under threshold
				{
					$score += $stats[$stat[1]][0] * $_POST[$stat[1].'weight'];
				}
			}
			else // no threshold was set
			{
				$score += $stats[$stat[1]][0] * $_POST[$stat[1].'weight'];
			}
		
			// revert stats to their unmodified state
			$stats = stats_derive($stats);
			$stats = modifications_undo($stats);
		}
	}
	return $score;
}