42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
use phpcommon;
|
|
|
|
class ShopChest
|
|
{
|
|
|
|
public static function getRandomItemListByChestType($chestType) {
|
|
self::cacheRandomItemListByChestTypes();
|
|
return getXVal(self::$itemListWithChestType, $chestType, null);
|
|
}
|
|
|
|
protected static function cacheRandomItemListByChestTypes() {
|
|
if (!self::$itemListWithChestType) {
|
|
self::$itemListWithChestType = array();
|
|
foreach (self::getMetaList() as $meta) {
|
|
if (!getXVal(self::$itemListWithChestType, $meta['chest_type'], null)) {
|
|
self::$itemListWithChestType[$meta['chest_type']] = array();
|
|
}
|
|
|
|
if(!getXVal(self::$itemListWithChestType[$meta['chest_type']], $meta['item_type'], null)) {
|
|
self::$itemListWithChestType[$meta['chest_type']][$meta['item_type']] = array();
|
|
}
|
|
|
|
array_push(self::$itemListWithChestType[$meta['chest_type']][$meta['item_type']], $meta);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected static function getMetaList()
|
|
{
|
|
if (!self::$metaList) {
|
|
self::$metaList = getMetaTable('Shopchest@Shopchest.php');
|
|
}
|
|
return self::$metaList;
|
|
}
|
|
|
|
protected static $itemListWithChestType;
|
|
protected static $metaList;
|
|
} |