game2006api/webapp/mt/Manufacture.php
hujiabin d887ba26a9 1
2024-04-19 16:20:26 +08:00

85 lines
2.1 KiB
PHP

<?php
namespace mt;
use phpcommon;
class Manufacture {
const SYN_ACTION = 1;
const UP_ACTION = 2;
public static function get($id)
{
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
}
public static function findHeroAction($action,$quality){
foreach (self::getHeroList() as $meta){
if ($meta['action'] == $action && $meta['rank'] == $quality){
return $meta;
}
}
return array();
}
public static function findChipAction($action,$quality){
foreach (self::getChipList() as $meta){
if ($meta['action'] == $action && $meta['rank'] == $quality){
return $meta;
}
}
return array();
}
public static function hashChance($chance){
if (!$chance){
return array();
}
$chanceStr = explode("|",$chance);
$hashChance = array();
foreach ($chanceStr as $value){
$arr = explode(":",$value);
$hashChance[$arr[0]] = $arr[1];
}
return $hashChance;
}
protected static function getHeroList(){
if (!self::$heroList) {
self::$heroList = array();
foreach (self::getMetaList() as $meta){
if ($meta['type'] == 1){
array_push(self::$heroList , $meta);
}
}
}
return self::$heroList;
}
protected static function getChipList(){
if (!self::$chipList) {
self::$chipList = array();
foreach (self::getMetaList() as $meta){
if ($meta['type'] == 2){
array_push(self::$chipList , $meta);
}
}
}
return self::$chipList;
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('manufacture@manufacture.php');
}
return self::$metaList;
}
protected static $metaList;
protected static $heroList;
protected static $chipList;
}