yas yas
item_stats.class.php
PHP Code:
<?php
class CItemInfo
{
private $m_ItemType = 0;
private $m_nCurParam = 0;
private $m_CurStatParams = array();
static $s_WeaponStatNames =
array('Durability', 'PhyReinforce', 'MagReinforce', 'HitRatio', 'PhyAttack', 'MagAttack', 'CriticalRatio');
static $s_EquipmentStatNames =
array('Durability', 'PhyReinforce', 'MagReinforce', 'PhyDefense', 'MagDefense', 'ParryRatio');
static $s_ShieldStatNames =
array('Durability', 'PhyReinforce', 'MagReinforce', 'BlockRatio', 'PhyDefense', 'MagDefense');
static $s_AccessoryStatNames =
array('PhyAbsorb', 'MagAbsorb');
public function __construct($item_type)
{
if($item_type > 3 || $item_type < 0) die("Item with type > 4 or < 0 !!1 (CItemInfo)!!");
$this -> m_ItemType = $item_type;
}
public function AddParam($param_value)
{
$this -> m_CurStatParams[$this -> m_nCurParam++] = $param_value;
}
public function GetParams()
{
$result = array(array());
switch($this -> m_ItemType)
{
case 0:
{
for($i = 0; $i < count (self::$s_WeaponStatNames); $i++)
{
$result[$i] =
array(self::$s_WeaponStatNames[$i] => $this -> m_CurStatParams[$i]);
}
}
break;
case 1:
{
for($i = 0; $i < count (self::$s_EquipmentStatNames); $i++)
{
$result[$i] =
array(self::$s_EquipmentStatNames[$i] => $this -> m_CurStatParams[$i]);
}
}
break;
case 2:
{
for($i = 0; $i < count (self::$s_ShieldStatNames); $i++)
{
$result[$i] =
array(self::$s_ShieldStatNames[$i] => $this -> m_CurStatParams[$i]);
}
}
break;
case 3:
{
for($i = 0; $i < count (self::$s_AccessoryStatNames); $i++)
{
$result[$i] =
array(self::$s_AccessoryStatNames[$i] => $this -> m_CurStatParams[$i]);
}
}
break;
}
return $result;
}
}
class CItemClass
{
static $s_Instance;
static $s_ItemTypes =
array('Weapon', 'Equipment', 'Shield', 'Accessory');
private function __construct()
{
}
protected function __clone()
{
}
static public function Instance()
{
if(is_null(self::$s_Instance))
{
self::$s_Instance = new self();
}
return self::$s_Instance;
}
//extract percentage from 32 bits
public function PercentageFromBitvalue($bitvalue)
{
return round(($bitvalue * 100 / 31) - 0.5 , 0);
}
public function GetVarianceDump($variance, $item_type_id)
{
$result = null;
$nCounter = 0;
//$variance = (ulong) $variance;
$g_Item = new CItemInfo($item_type_id);
while($variance > 0)
{
$cur_stat = $variance & 0x1F;
$g_Item -> AddParam($this -> PercentageFromBitvalue($cur_stat));
$variance >>= 5;
}
print_r($g_Item -> GetParams());
return $g_Item -> GetParams();
}
}
?>
get_whitestats.php
PHP Code:
<html>
<head>
<title>squirrel</title>
</head>
<body>
<center>
<table border = '1' cellspacing = '2' cellpadding = '2'>
<form method='post'>
<td>Variance</td><td><input type='text' name='variance'></td><tr/>
<td>ItemType</td>
<td>
<select name = 'item_type'>
<option value='0'>Weapon</option>
<option value='1'>Armor</option>
<option value='2'>Shield</option>
<option value='3'>Accessory</option>
</select>
</td>
<td></td><td><input type='submit' value='GIV'></td>
</form>
</table>
</center>
</body>
</html>
<?php
if(!empty($_POST['variance']))
{
include('item_stats.class.php');
$instance = CItemClass::Instance();
//$a = (long) ($_POST['variance']);
$instance -> GetVarianceDump((float)($_POST['variance']), $_POST['item_type']);
}
?>
credits goes to the squirrel