74 lines
1.9 KiB
PHP
74 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
use phpcommon;
|
|
|
|
class Hero {
|
|
|
|
public static function get($id)
|
|
{
|
|
return getXVal(self::getMetaList(), $id);
|
|
}
|
|
|
|
public static function getDefaultSkin($meta)
|
|
{
|
|
$values = explode('|', $meta["skinlist"]);
|
|
return count($values) > 0 ? $values[0] : 0;
|
|
}
|
|
|
|
public static function getHeroAttr($meta)
|
|
{
|
|
$fields = array(
|
|
array(//生命值-固定值
|
|
'attr_id' => kHAT_Hp,
|
|
'type' => kHAT_ABS_VAL,
|
|
'field_name' => 'hp'
|
|
),
|
|
array(//攻击力-固定值
|
|
'attr_id' => kHAT_Atk,
|
|
'type' => kHAT_ABS_VAL,
|
|
'field_name' => 'damage'
|
|
),
|
|
array(//防御-固定值
|
|
'attr_id' => kHAT_Def,
|
|
'type' => kHAT_ABS_VAL,
|
|
'field_name' => 'defence'
|
|
),
|
|
array(//移动速度-固定值
|
|
'attr_id' => kHAT_Speed,
|
|
'type' => kHAT_ABS_VAL,
|
|
'field_name' => 'move_speed'
|
|
),array(//暴击率-百分比
|
|
'attr_id' => kHAT_Critical,
|
|
'type' => kHAT_RATE_VAL,
|
|
'field_name' => 'crit_atk'
|
|
),array(//暴击伤害-百分比
|
|
'attr_id' => kHAT_CriDamage,
|
|
'type' => kHAT_RATE_VAL,
|
|
'field_name' => 'crit_atk_damage'
|
|
)
|
|
);
|
|
$attr = array();
|
|
foreach ($fields as $field) {
|
|
array_push($attr, array(
|
|
'attr_id' => $field['attr_id'],
|
|
'type' => $field['type'],
|
|
'val' => $meta[$field['field_name']]
|
|
));
|
|
}
|
|
return $attr;
|
|
}
|
|
|
|
protected static function getMetaList()
|
|
{
|
|
if (!self::$metaList) {
|
|
self::$metaList = getMetaTable('hero@hero.php');
|
|
}
|
|
return self::$metaList;
|
|
}
|
|
|
|
protected static $metaList;
|
|
|
|
}
|