game2006api/webapp/mt/CircuitTime.php
hujiabin 776818f7f6 1
2024-10-16 16:57:44 +08:00

95 lines
2.6 KiB
PHP

<?php
namespace mt;
use phpcommon;
class CircuitTime {
const WHOLE_SEASON__TYPE = 1;
const STAGE_SEASON_TYPE = 2;
public static function getCurrentCircuit(){
foreach (self::getCircuitAll(self::WHOLE_SEASON__TYPE) as $meta){
if (myself()->_getNowTime() >= strtotime($meta['start_time']) &&
myself()->_getNowTime() <= strtotime($meta['end_time'])) {
return $meta;
}
}
return null;
}
public static function getNextCircuit(){
$next = array();
foreach (self::getCircuitAll(self::WHOLE_SEASON__TYPE) as $meta){
if (myself()->_getNowTime() < strtotime($meta['start_time'])){
$next = $meta;
break;
}
}
return $next;
}
public static function getPrevStage(){
$prev = array();
foreach (self::getCircuitAll(self::STAGE_SEASON_TYPE) as $meta){
if (myself()->_getNowTime() > strtotime($meta['end_time'])){
$prev = $meta;
}
}
return $prev;
}
public static function getCurrentStage(){
foreach (self::getCircuitAll(self::STAGE_SEASON_TYPE) as $meta){
if (myself()->_getNowTime() >= strtotime($meta['start_time']) &&
myself()->_getNowTime() <= strtotime($meta['end_time'])) {
return $meta;
}
}
return null;
}
public static function getNextStage($season){
$next = array();
foreach (self::getListBySeason($season) as $meta){
if (myself()->_getNowTime() < strtotime($meta['start_time'])){
$next = $meta;
break;
}
}
return $next;
}
public static function getCircuitAll($type){
$metas =array();
foreach (self::getMetaList() as $meta){
if ($meta['circuit_time_type'] == $type){
array_push($metas,$meta);
}
}
return $metas;
}
public static function getListBySeason($season){
$metas =array();
foreach (self::getMetaList() as $meta){
if ($meta['circuit_season'] == $season && $meta['circuit_time_type'] == self::STAGE_SEASON_TYPE){
array_push($metas,$meta);
}
}
return $metas;
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('CircuitTime@CircuitTime.php');
}
return self::$metaList;
}
protected static $metaList;
}