1
This commit is contained in:
parent
ebdbd71f6c
commit
4757cbf4a3
@ -40,8 +40,8 @@ class Battle(object):
|
||||
['weapons_slot', '', '武器信息 weapon_id:use_times|'],
|
||||
['heros', '', '武器信息 hero_id:skill_lv:weapon_lv|'],
|
||||
|
||||
#['rank_score', 0, '排位积分'],
|
||||
['pass_score', 0, '通行证积分'],
|
||||
['rank_score', 0, '排位积分'],
|
||||
#['pass_score', 0, '通行证积分'],
|
||||
['items', 0, '道具|分割'],
|
||||
],
|
||||
'response': [
|
||||
|
@ -16,6 +16,26 @@ class Rank {
|
||||
return self::get(1);
|
||||
}
|
||||
|
||||
public static function calcNewRankAndScore($oldRank, $oldScore, &$newRank, &$newScore, $addScore)
|
||||
{
|
||||
$currRankMeta = self::get($oldRank);
|
||||
if ($currRankMeta && $currRankMeta['max_score'] > 0) {
|
||||
$newScore = min($oldScore, $currRankMeta['max_score']) + $addScore;
|
||||
do {
|
||||
if ($newScore > $currRankMeta['max_score']) {
|
||||
++$newRank;
|
||||
$currRankMeta = self::get($newRank);
|
||||
if ($currRankMeta['max_score'] < 0) {
|
||||
$newScore = $currRankMeta['min_score'];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while ($currRankMeta);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
|
@ -5,6 +5,7 @@ namespace services;
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Equip.php');
|
||||
require_once('mt/Season.php');
|
||||
require_once('mt/Rank.php');
|
||||
|
||||
require_once('models/Season.php');
|
||||
require_once('models/Battle.php');
|
||||
@ -32,6 +33,7 @@ class BattleDataService extends BaseService {
|
||||
if (!$this->seasonDb) {
|
||||
return;
|
||||
}
|
||||
$this->updateScore();
|
||||
$hisBattleData = Battle::getMyBattleData();
|
||||
if (!isset($hisBattleData)) {
|
||||
$hisBattleData = array(
|
||||
@ -241,4 +243,26 @@ class BattleDataService extends BaseService {
|
||||
$battleData[$key] = max(getXVal($battleData, $key, 0), $val);
|
||||
}
|
||||
|
||||
private function updateScore()
|
||||
{
|
||||
$userInfo = myself()->_getOrmUserInfo();
|
||||
$rankScore = getReqVal('rank_score', 0);
|
||||
if ($rankScore > 0) {
|
||||
$newRank = $userInfo['rank'];
|
||||
$newScore = $userInfo['score'];
|
||||
mt\Rank::calcNewRankAndScore($userInfo['rank'], $userInfo['score'], $newRank, $newScore, $rankScore);
|
||||
if ($newRank >= $userInfo['rank'] && $newScore != $userInfo['score']) {
|
||||
myself()->_updateUserInfo(array(
|
||||
'rank' => $newRank,
|
||||
'score' => $newScore,
|
||||
'history_best_rank' => max($userInfo['rank'], $newRank)
|
||||
));
|
||||
Season::update($this->currSeasonMeta['id'], array(
|
||||
'rank' => $newRank,
|
||||
'score' => $newScore
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user