This commit is contained in:
aozhiwei 2024-11-09 14:38:59 +08:00
parent 424acd4b6d
commit 377dd51fa8

View File

@ -209,6 +209,14 @@ class CircuitRankingService extends BaseService {
} }
} }
$sortRows = myself()->arraySort($data, 'cumulative_score', 'desc'); $sortRows = myself()->arraySort($data, 'cumulative_score', 'desc');
{
for ($i = 0; $i < 200; ++$i) {
array_push($sortRows, array(
'account_id' => $i,
'cumulative_score' => 1000 - $i
));
}
}
if (count($sortRows) <= 20) { if (count($sortRows) <= 20) {
myself()->_rspErr(1, '人数不足20'); myself()->_rspErr(1, '人数不足20');
return; return;
@ -237,7 +245,7 @@ class CircuitRankingService extends BaseService {
$rangeScore = $lastScore - $currScore; $rangeScore = $lastScore - $currScore;
$allocScore = $currScore + rand(0, $rangeScore - 1); $allocScore = $currScore + rand(0, $rangeScore - 1);
$curAndroid = $sortAndroids[$i]; $curAndroid = $sortAndroids[$i];
self::updateAndroid($curAndroid, $allocScore, $currentStageMeta); self::updateAndroidScore($curAndroid, $allocScore, $currentStageMeta);
$lastScore = $currScore; $lastScore = $currScore;
} }
myself()->_rspOk(); myself()->_rspOk();
@ -248,22 +256,20 @@ class CircuitRankingService extends BaseService {
if ($newScore <= $android['cumulative_score']) { if ($newScore <= $android['cumulative_score']) {
return; return;
} }
if ($curAndroid['cumulative_score'] <= 0) { if ($android['cumulative_score'] <= 0) {
SqlHelper::upsert SqlHelper::upsert
($this->_getMysql(''), (myself()->_getMysql(''),
't_circuit_battle', 't_circuit_battle',
array( array(
'account_id' => $android['robot_id'], 'account_id' => $android['account_id'],
'season' => $currentStageMeta['circuit_season'], 'season' => $currentStageMeta['circuit_season'],
'phase' => $currentStageMeta['circuit_phase'],
), ),
array( array(
'cumulative_score' => $newScore, 'cumulative_score' => $newScore,
), ),
array( array(
'account_id' => $android['robot_id'], 'account_id' => $android['account_id'],
'season' => $currentStageMeta['circuit_season'], 'season' => $currentStageMeta['circuit_season'],
'phase' => $currentStageMeta['circuit_phase'],
'is_android' => 1, 'is_android' => 1,
'cumulative_score' => $newScore, 'cumulative_score' => $newScore,
'createtime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(),
@ -272,12 +278,11 @@ class CircuitRankingService extends BaseService {
); );
} else { } else {
SqlHelper::upsert SqlHelper::upsert
($this->_getMysql(''), (myself()->_getMysql(''),
't_circuit_battle', 't_circuit_battle',
array( array(
'account_id' => $android['robot_id'], 'account_id' => $android['account_id'],
'season' => $currentStageMeta['circuit_season'], 'season' => $currentStageMeta['circuit_season'],
'phase' => $currentStageMeta['circuit_phase'],
), ),
array( array(
'cumulative_score' => function() use($android, $newScore) { 'cumulative_score' => function() use($android, $newScore) {
@ -286,9 +291,8 @@ class CircuitRankingService extends BaseService {
}, },
), ),
array( array(
'account_id' => $android['robot_id'], 'account_id' => $android['account_id'],
'season' => $currentStageMeta['circuit_season'], 'season' => $currentStageMeta['circuit_season'],
'phase' => $currentStageMeta['circuit_phase'],
'is_android' => 1, 'is_android' => 1,
'cumulative_score' => $newScore, 'cumulative_score' => $newScore,
'createtime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(),
@ -297,10 +301,10 @@ class CircuitRankingService extends BaseService {
); );
} }
SqlHelper::update SqlHelper::update
($this->_getMysql(''), (myself()->_getMysql(''),
't_circuit_battle', 't_circuit_battle_phase',
array( array(
'account_id' => $android['robot_id'], 'account_id' => $android['account_id'],
'season' => $currentStageMeta['circuit_season'], 'season' => $currentStageMeta['circuit_season'],
'phase' => $currentStageMeta['circuit_phase'], 'phase' => $currentStageMeta['circuit_phase'],
), ),