From 5e236787347296d4082afe6673dec47c0d522cab Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Fri, 15 Oct 2021 22:48:10 +0800 Subject: [PATCH 1/5] [fix] Judge fixed#128 --- src/plugin/Judge.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/plugin/Judge.php b/src/plugin/Judge.php index 9b52137..ab70a6c 100644 --- a/src/plugin/Judge.php +++ b/src/plugin/Judge.php @@ -51,16 +51,19 @@ class Judge // 获取任务 $case_id = self::caseObtain(); self::caseCheck($case_id); - self::setLock(1 * 60 + 5); - return; + // 如果没有设置时间 就设置个默认时间 可能在一秒钟内处理完 所以 <= + if (self::getLock() <= time()) { + self::setLock(1 * 60 + 5); + } } else { $case = array_pop(self::$wait_case); self::vote($case['id'], $case['vote']); + // 如果没有设置时间 就设置个默认时间 可能在一秒钟内处理完 所以 <= + if (self::getLock() <= time()) { + self::setLock(mt_rand(15, 30) * 60); + } } - // 如果没有设置时间 就设置个默认时间 可能在一秒钟内处理完 所以 <= - if (self::getLock() <= time()) { - self::setLock(mt_rand(15, 30) * 60); - } + } From e6fd8b39697521dd27cb4cfc98da577a8e799c2d Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:44:56 +0800 Subject: [PATCH 2/5] [update] Judge --- src/plugin/Judge.php | 47 ++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/plugin/Judge.php b/src/plugin/Judge.php index ab70a6c..004364b 100644 --- a/src/plugin/Judge.php +++ b/src/plugin/Judge.php @@ -46,22 +46,19 @@ class Judge if (!self::jury()) { self::setLock(mt_rand(60, 120) * 60); } - // + // 任务 if (empty(self::$wait_case)) { - // 获取任务 + // 获取 $case_id = self::caseObtain(); self::caseCheck($case_id); - // 如果没有设置时间 就设置个默认时间 可能在一秒钟内处理完 所以 <= - if (self::getLock() <= time()) { - self::setLock(1 * 60 + 5); - } } else { + // 执行 $case = array_pop(self::$wait_case); self::vote($case['id'], $case['vote']); - // 如果没有设置时间 就设置个默认时间 可能在一秒钟内处理完 所以 <= - if (self::getLock() <= time()) { - self::setLock(mt_rand(15, 30) * 60); - } + } + // 如果没有设置时间 就设置个默认时间 可能在一秒钟内处理完 所以 <= + if (self::getLock() <= time()) { + self::setLock(mt_rand(15, 30) * 60); } } @@ -74,13 +71,14 @@ class Judge */ private static function caseCheck($case_id) { - if ($case_id == "") { + if ($case_id == '') { return true; } $case_info = self::caseInfo($case_id); $case_opinion = self::caseOpinion($case_id); if (!$case_opinion && empty($case_opinion)) { - $vote_info = $case_info[array_rand($case_info)]; +// $vote_info = $case_info[array_rand($case_info)]; + $vote_info = $case_info[self::probability()]; } else { $vote_info = $case_opinion[array_rand($case_opinion)]; @@ -89,6 +87,7 @@ class Judge $vote_text = $vote_info['vote_text']; Log::info("案件 $case_id 的预测投票结果:$vote($vote_text)"); array_push(self::$wait_case, ["id" => $case_id, 'vote' => $vote]); + self::setLock(1 * 60 + 5); } /** @@ -112,7 +111,8 @@ class Judge ]; $raw = Curl::post('pc', $url, $payload, $headers); $de_raw = json_decode($raw, true); - //{"code":0,"message":"0","ttl":1} + // {"code":0,"message":"0","ttl":1} + // {"code":25018,"message":"不能进行此操作","ttl":1} if (isset($de_raw['code']) && $de_raw['code']) { Log::warning("案件 $case_id 投票失败 $raw"); } else { @@ -303,4 +303,25 @@ class Judge return implode("", $temp); } + /** + * @use 概率 + * @return int + */ + private static function probability(): int + { + $result = 0; + $prize_arr = [0 => 25, 1 => 40, 2 => 25, 3 => 10]; + // 概率数组的总概率精度 + $sum = array_sum($prize_arr); + // 概率数组循环 + foreach ($prize_arr as $key => $value) { + if (mt_rand(1, $sum) <= $value) { + $result = $key; + break; + } + $sum -= $value; + } + return $result; + } + } \ No newline at end of file From 106eac15cb1f10c3fa83024c72eb5c8f0129db57 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Sun, 24 Oct 2021 15:50:50 +0800 Subject: [PATCH 3/5] [fix] Judge closed #129 --- src/plugin/Judge.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugin/Judge.php b/src/plugin/Judge.php index 004364b..2ff6d94 100644 --- a/src/plugin/Judge.php +++ b/src/plugin/Judge.php @@ -87,6 +87,9 @@ class Judge $vote_text = $vote_info['vote_text']; Log::info("案件 $case_id 的预测投票结果:$vote($vote_text)"); array_push(self::$wait_case, ["id" => $case_id, 'vote' => $vote]); + // 尝试修复25018 未测试 + self::vote($case_id, 0); + self::setLock(1 * 60 + 5); } From 1849ccbf9a9abecef2af6aa0ff6e62da26fdfade Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Sun, 24 Oct 2021 17:55:38 +0800 Subject: [PATCH 4/5] [fix] GiftSend closed #127 --- src/plugin/Barrage.php | 2 +- src/plugin/GiftSend.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugin/Barrage.php b/src/plugin/Barrage.php index 463f922..bb692a9 100644 --- a/src/plugin/Barrage.php +++ b/src/plugin/Barrage.php @@ -26,7 +26,7 @@ class Barrage } self::setPauseStatus(); if (self::sendMsg()) { - self::setLock(mt_rand(180, 240) * 60); + self::setLock(mt_rand(240, 300) * 60); return; } self::setLock(15 * 60); diff --git a/src/plugin/GiftSend.php b/src/plugin/GiftSend.php index 455a482..d6ea132 100644 --- a/src/plugin/GiftSend.php +++ b/src/plugin/GiftSend.php @@ -73,8 +73,8 @@ class GiftSend } $current_intimacy = 0; foreach ($bag_list as $gift) { - // 是辣条、亿元 && 不是过期礼物 - if (!in_array($gift['gift_id'], [1, 6])) { + // 是辣条、亿元 && 不是过期礼物 加入小心心,暂不清楚是否有逻辑冲突 + if (!in_array($gift['gift_id'], [1, 6, 30607])) { continue; } Log::notice("直播间 $room_id 需赠送亲密度 $total_intimacy 剩余亲密度 " . ($total_intimacy - $current_intimacy)); From b702d7466317b3471472b7efb1c005c581479852 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Sun, 24 Oct 2021 18:01:05 +0800 Subject: [PATCH 5/5] [fix] Competition closed #133 --- src/plugin/Competition.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/Competition.php b/src/plugin/Competition.php index 1a88543..788f5f1 100644 --- a/src/plugin/Competition.php +++ b/src/plugin/Competition.php @@ -88,7 +88,7 @@ class Competition $guess['oid'] = $question['contest']['id']; $guess['main_id'] = $question['questions'][0]['id']; $details = $question['questions'][0]['details']; - $guess['count'] = ($count = getConf('max_coin', 'match_forecast') <= 10) ? $count : 10; + $guess['count'] = (($count = getConf('max_coin', 'match_forecast')) <= 10) ? $count : 10; $guess['title'] = $question['questions'][0]['title']; foreach ($details as $detail) { $guess['title'] .= " 队伍: {$detail['option']} 赔率: {$detail['odds']}";