From 83d5adeb8664de9829bc7cd7cc8eca49dcea5c05 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Sun, 28 Jun 2020 11:27:01 +0800 Subject: [PATCH] [fix] Statistics --- src/plugin/Competition.php | 6 ++++-- src/plugin/Statistics.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugin/Competition.php b/src/plugin/Competition.php index 5868b50..aba68e9 100644 --- a/src/plugin/Competition.php +++ b/src/plugin/Competition.php @@ -18,6 +18,9 @@ class Competition { use TimeLock; + /** + * @use 赛事入口 https://www.bilibili.com/v/game/match/competition + */ public static function run() { if (getenv('USE_COMPETITION') == 'false' || self::getLock() > time()) { @@ -37,10 +40,9 @@ class Competition $questions = self::fetchQuestions(); $max_guess = intval(getenv('COMPET_MAX_NUM')); foreach ($questions as $index => $question) { - if (($index + 1) >= $max_guess) { + if ($index >= $max_guess) { break; } - // int $, int $main_id, int $detail_id, int $coin_num $guess = self::parseQuestion($question); self::addGuess($guess); } diff --git a/src/plugin/Statistics.php b/src/plugin/Statistics.php index da60bdb..51ae81d 100644 --- a/src/plugin/Statistics.php +++ b/src/plugin/Statistics.php @@ -169,7 +169,7 @@ class Statistics $results = 0; is_null($second_key) ? self::initKeyValue($target, $key) : self::initKeyValue($target, $key, 0, $second_key); foreach ($target as $item) { - $skip = is_null($second_key) ? isset($item[$key]) : $item[$key][$second_key]; + $skip = is_null($second_key) ? isset($item[$key]) : isset($item[$key][$second_key]); if ($skip) { is_null($second_key) ? $results += intval($item[$key]) : $results += intval($item[$key][$second_key]); }