80 lines
1.9 KiB
PHP
80 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
use phpcommon;
|
|
|
|
class Rank {
|
|
|
|
public static function get($id)
|
|
{
|
|
return getXVal(self::getMetaList(), $id);
|
|
}
|
|
|
|
public static function getRankById($id)
|
|
{
|
|
return getXVal(self::getMetaListNew(), $id);
|
|
}
|
|
|
|
public static function getNextRankById($id)
|
|
{
|
|
return getXVal(self::getMetaListNew(), $id+1);
|
|
}
|
|
|
|
public static function getMaxRank()
|
|
{
|
|
$temp = array();
|
|
foreach (self::getMetaListNew() as $mate){
|
|
array_push($temp,$mate['id']);
|
|
}
|
|
return self::getRankById(max($temp));
|
|
}
|
|
|
|
public static function getInitRank()
|
|
{
|
|
return self::get(1);
|
|
}
|
|
|
|
public static function calcNewRankAndScore( &$newRank, &$newScore)
|
|
{
|
|
$meta = self::getMetaListNew();
|
|
for ($i=1;$i<=count($meta);$i++){
|
|
if ($meta[$i]['id'] == 1){
|
|
$newScore = max($newScore,$meta[$i]['rank_score']);
|
|
}
|
|
// if ($meta[$i]['id'] == count($meta)){
|
|
// $newScore = min($newScore,$meta[$i]['rank_score']);
|
|
// }
|
|
if ($i+1<=count($meta)){
|
|
if($newScore>=$meta[$i]['rank_score'] && $newScore<$meta[$i+1]['rank_score']){
|
|
$newRank = $meta[$i]['id'];
|
|
}
|
|
}else{
|
|
if($newScore>=$meta[$i]['rank_score']){
|
|
$newRank = $meta[$i]['id'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected static function getMetaList()
|
|
{
|
|
if (!self::$metaList) {
|
|
self::$metaList = getMetaTable('rank@rank.php');
|
|
}
|
|
return self::$metaList;
|
|
}
|
|
|
|
protected static function getMetaListNew()
|
|
{
|
|
if (!self::$metaListNew) {
|
|
self::$metaListNew = getMetaTable('rankRank@rankRank.php');
|
|
}
|
|
return self::$metaListNew;
|
|
}
|
|
|
|
protected static $metaList;
|
|
protected static $metaListNew;
|
|
|
|
}
|