1
This commit is contained in:
parent
bdca825286
commit
f482467242
@ -14,15 +14,62 @@ class HeroLevelAttr {
|
|||||||
return getXVal(self::getMetaList(), $id);
|
return getXVal(self::getMetaList(), $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addRandAttr($level, $baseAttrs, &$dbAttrs)
|
public static function addRandAttr($level, &$dbAttrs)
|
||||||
{
|
{
|
||||||
$nums = explode(':', $levelMeta['rand_attrs_num']);
|
$newAttrs = array();
|
||||||
$num = rand($nums[0], $nums[1]);
|
foreach (self::getMetaList() as $meta) {
|
||||||
$cfgAttrs = StrHelper::parseList($levelMeta['rand_attrs'], array('|', ':'));
|
if ($meta['level'] == $level) {
|
||||||
AttrHelper::addRandAttrs($cfgAttrs, $num, $baseAttrs, $dbAttrs);
|
if (in_array(
|
||||||
|
$meta['type'],
|
||||||
|
array(
|
||||||
|
kHAT_ABS_VAL,
|
||||||
|
kHAT_RATE_VAL
|
||||||
|
)
|
||||||
|
)) {
|
||||||
|
$val = self::getAttrValue($meta);
|
||||||
|
if ($val > 0) {
|
||||||
|
array_push(array(
|
||||||
|
'attr_id' => $meta['attr_id'],
|
||||||
|
'type' => $meta['type'],
|
||||||
|
'val' => $val,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AttrHelper::addRandAttrs($dbAttrs, $newAttrs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function getAttrValue($meta)
|
||||||
|
{
|
||||||
|
$strs = explode('|', $meta['attr_weight']);
|
||||||
|
|
||||||
|
$totalSpace = 0;
|
||||||
|
foreach ($strs as $tmpStr) {
|
||||||
|
$strs2 = explode(':', $tmpStr);
|
||||||
|
if (count($str2) == 2) {
|
||||||
|
$totalSpace += $str2[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($totalSpace > 0) {
|
||||||
|
$randSpace = rand(0, $totalSpace);
|
||||||
|
$currSpace = 0;
|
||||||
|
foreach ($strs as $tmpStr) {
|
||||||
|
$strs2 = explode(':', $tmpStr);
|
||||||
|
if (count($str2) == 2) {
|
||||||
|
$currSpace += $str2[1];
|
||||||
|
}
|
||||||
|
if ($randSpace <= $currSpace) {
|
||||||
|
return $str2[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected static function getMetaList()
|
protected static function getMetaList()
|
||||||
{
|
{
|
||||||
if (!self::$metaList) {
|
if (!self::$metaList) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user