game2006api/webapp/mt/SeasonPoint.php
2021-11-23 12:04:34 +08:00

64 lines
1.6 KiB
PHP

<?php
namespace mt;
use phpcommon;
class SeasonPoint {
public static function get($id)
{
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
}
public static function getOldSeasonPoint($id)
{
$meta = self::get($id);
return array(
'id' => $meta['id'],
'min' => $meta['min_point'],
'max' => $meta['max_point'],
'des' => $meta['des'],
'topoint' => $meta['topoint'],
'is_protect' => $meta['is_protect'],
);
}
public static function calcTopoint($userInfo)
{
$integral = 0;
foreach (self::getMetaList() as $meta) {
if ($userInfo['integral'] <= $meta['max_point'] ||
$meta['max_point'] == -1) {
$integral = $meta['topoint'];
break;
}
}
return $integral;
}
public static function calcScore($integral, &$isProtect, &$minScore)
{
$isProtect = false;
$minScore = 0;
foreach (self::getMetaList() as $meta) {
if ($integral >= $meta['min'] && $integral <= $meta['max']
|| $integral >= $meta['min'] && $meta['max'] == -1) {
$isProtect = $meta['is_protect'];
$minScore = $meta['min'];
}
}
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('seasomPoint@seasomPoint.php');
}
return self::$metaList;
}
protected static $metaList;
}