This commit is contained in:
aozhiwei 2024-08-01 17:58:38 +08:00
parent 681cb9e719
commit f8008af8cc

View File

@ -135,9 +135,13 @@ class BigwheelController extends BaseAuthedController {
$randSpace2 += $item['meta']['reWeight']; $randSpace2 += $item['meta']['reWeight'];
$item['weight'] = $randSpace2; $item['weight'] = $randSpace2;
} }
$rnd1 = rand(0, $randSpace1 - 1);
$rnd2 = rand(0, $randSpace2 - 1);
error_log(json_encode(array( error_log(json_encode(array(
'randSpace1' => $randSpace1, 'randSpace1' => $randSpace1,
'randSpace2' => $randSpace2, 'randSpace2' => $randSpace2,
'rnd1' => $rnd1,
'rnd2' => $rnd2,
'item1Arr' => $item1Arr, 'item1Arr' => $item1Arr,
'item2Arr' => $item2Arr, 'item2Arr' => $item2Arr,
))); )));
@ -148,9 +152,8 @@ class BigwheelController extends BaseAuthedController {
} }
$item1 = null; $item1 = null;
{ {
$rnd = rand(0, $randSpace1 - 1);
foreach ($item1Arr as $item) { foreach ($item1Arr as $item) {
if ($rnd <= $item['weight']) { if ($rnd1 <= $item['weight']) {
$item1 = $item; $item1 = $item;
break; break;
} }
@ -158,9 +161,8 @@ class BigwheelController extends BaseAuthedController {
} }
$item2 = null; $item2 = null;
{ {
$rnd = rand(0, $randSpace2 - 2);
foreach ($item2Arr as $item) { foreach ($item2Arr as $item) {
if ($rnd <= $item['weight']) { if ($rnd2 <= $item['weight']) {
$item2 = $item; $item2 = $item;
break; break;
} }