From 377dd51fa8bb12e0b2f39670253bb97c464d7c99 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 9 Nov 2024 14:38:59 +0800 Subject: [PATCH] 1 --- webapp/services/CircuitRankingService.php | 34 +++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/webapp/services/CircuitRankingService.php b/webapp/services/CircuitRankingService.php index 3ccbe572..86e0d11b 100644 --- a/webapp/services/CircuitRankingService.php +++ b/webapp/services/CircuitRankingService.php @@ -209,6 +209,14 @@ class CircuitRankingService extends BaseService { } } $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) { myself()->_rspErr(1, '人数不足20'); return; @@ -237,7 +245,7 @@ class CircuitRankingService extends BaseService { $rangeScore = $lastScore - $currScore; $allocScore = $currScore + rand(0, $rangeScore - 1); $curAndroid = $sortAndroids[$i]; - self::updateAndroid($curAndroid, $allocScore, $currentStageMeta); + self::updateAndroidScore($curAndroid, $allocScore, $currentStageMeta); $lastScore = $currScore; } myself()->_rspOk(); @@ -248,22 +256,20 @@ class CircuitRankingService extends BaseService { if ($newScore <= $android['cumulative_score']) { return; } - if ($curAndroid['cumulative_score'] <= 0) { + if ($android['cumulative_score'] <= 0) { SqlHelper::upsert - ($this->_getMysql(''), + (myself()->_getMysql(''), 't_circuit_battle', array( - 'account_id' => $android['robot_id'], + 'account_id' => $android['account_id'], 'season' => $currentStageMeta['circuit_season'], - 'phase' => $currentStageMeta['circuit_phase'], ), array( 'cumulative_score' => $newScore, ), array( - 'account_id' => $android['robot_id'], + 'account_id' => $android['account_id'], 'season' => $currentStageMeta['circuit_season'], - 'phase' => $currentStageMeta['circuit_phase'], 'is_android' => 1, 'cumulative_score' => $newScore, 'createtime' => myself()->_getNowTime(), @@ -272,12 +278,11 @@ class CircuitRankingService extends BaseService { ); } else { SqlHelper::upsert - ($this->_getMysql(''), + (myself()->_getMysql(''), 't_circuit_battle', array( - 'account_id' => $android['robot_id'], + 'account_id' => $android['account_id'], 'season' => $currentStageMeta['circuit_season'], - 'phase' => $currentStageMeta['circuit_phase'], ), array( 'cumulative_score' => function() use($android, $newScore) { @@ -286,9 +291,8 @@ class CircuitRankingService extends BaseService { }, ), array( - 'account_id' => $android['robot_id'], + 'account_id' => $android['account_id'], 'season' => $currentStageMeta['circuit_season'], - 'phase' => $currentStageMeta['circuit_phase'], 'is_android' => 1, 'cumulative_score' => $newScore, 'createtime' => myself()->_getNowTime(), @@ -297,10 +301,10 @@ class CircuitRankingService extends BaseService { ); } SqlHelper::update - ($this->_getMysql(''), - 't_circuit_battle', + (myself()->_getMysql(''), + 't_circuit_battle_phase', array( - 'account_id' => $android['robot_id'], + 'account_id' => $android['account_id'], 'season' => $currentStageMeta['circuit_season'], 'phase' => $currentStageMeta['circuit_phase'], ),