game2006api/webapp/mt/Hero.php
aozhiwei 45c161a6e9 1
2022-01-12 19:10:35 +08:00

62 lines
1.4 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,
'field_name' => 'hp'
),
array(
'attr_id' => kHAT_Atk,
'field_name' => 'damage'
),
array(
'attr_id' => kHAT_Def,
'field_name' => 'defence'
),
array(
'attr_id' => kHAT_Speed,
'field_name' => 'move_speed'
),
);
$attr = array();
foreach ($fields as $field) {
array_push($attr, array(
'attr_id' => $field['attr_id'],
'type' => kHAT_ABS_VAL,
'val' => (int)$meta[$field['field_name']]
));
}
return $attr;
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('player@player.php');
}
return self::$metaList;
}
protected static $metaList;
}