game2006api/webapp/mt/BattlePass.php
2023-06-16 11:40:15 +08:00

69 lines
1.7 KiB
PHP

<?php
namespace mt;
class BattlePass
{
public static function find($id){
return getXVal(self::getMetaList(), $id);
}
public static function all(){
return self::getMetaList();
}
public static function getExpByLv(&$lv,&$exp){
$meta = self::getMetaList();
if ($exp > 0){
for ($i=1;$i<=count($meta);$i++){
if ($exp >= $meta[count($meta)]['total_exp']){
$exp = min($exp, $meta[count($meta)]['total_exp']);
$lv = $meta[count($meta)]['id'];
}else{
if ($i<count($meta)){
if ($exp >= $meta[$i]['total_exp'] &&
$exp < $meta[$i+1]['total_exp'])
{
$lv = $meta[$i]['id'];
}
}
}
}
}
}
public static function getCurrentSeason(){
foreach (self::getMetaCommon() as $meta) {
if (myself()->_getNowTime() >= strtotime($meta['begin_time']) &&
myself()->_getNowTime() <= strtotime($meta['end_time'])) {
return $meta;
}
}
return null;
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('Battlepass@Battlepass.php');
}
return self::$metaList;
}
protected static function getMetaCommon()
{
if (!self::$metaCommon) {
self::$metaCommon = getMetaTable('BattlepassCommon@BattlepassCommon.php');
}
return self::$metaCommon;
}
protected static $metaList;
protected static $metaCommon;
}