From f8008af8cc6b6ba03ba59011c6f56b07b0c488c0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 17:58:38 +0800 Subject: [PATCH] 1 --- webapp/controller/BigwheelController.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index c36ca0bf..a687e40f 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -135,9 +135,13 @@ class BigwheelController extends BaseAuthedController { $randSpace2 += $item['meta']['reWeight']; $item['weight'] = $randSpace2; } + $rnd1 = rand(0, $randSpace1 - 1); + $rnd2 = rand(0, $randSpace2 - 1); error_log(json_encode(array( 'randSpace1' => $randSpace1, 'randSpace2' => $randSpace2, + 'rnd1' => $rnd1, + 'rnd2' => $rnd2, 'item1Arr' => $item1Arr, 'item2Arr' => $item2Arr, ))); @@ -148,9 +152,8 @@ class BigwheelController extends BaseAuthedController { } $item1 = null; { - $rnd = rand(0, $randSpace1 - 1); foreach ($item1Arr as $item) { - if ($rnd <= $item['weight']) { + if ($rnd1 <= $item['weight']) { $item1 = $item; break; } @@ -158,9 +161,8 @@ class BigwheelController extends BaseAuthedController { } $item2 = null; { - $rnd = rand(0, $randSpace2 - 2); foreach ($item2Arr as $item) { - if ($rnd <= $item['weight']) { + if ($rnd2 <= $item['weight']) { $item2 = $item; break; }