This commit is contained in:
aozhiwei 2024-08-01 17:29:28 +08:00
parent 2b266d045a
commit 9d327bcaad

View File

@ -88,7 +88,8 @@ class BigwheelController extends BaseAuthedController {
mt\Bigwheel::traverseMeta( mt\Bigwheel::traverseMeta(
function ($meta) use(&$data, &$item1Hash, &$item2Hash, &$item1Arr, &$item2Arr) { function ($meta) use(&$data, &$item1Hash, &$item2Hash, &$item1Arr, &$item2Arr) {
$gridRef = null; $gridRef = null;
$this->getGridRefByGridId($data, $meta['id'], $girdRef); $this->getGridRefByGridId($data, $meta['id'], $gridRef);
if (empty($gridRef)) {
switch ($meta['Wheel_type']) { switch ($meta['Wheel_type']) {
case 1:{ case 1:{
$item1Hash[$meta['id']] = $meta; $item1Hash[$meta['id']] = $meta;
@ -107,6 +108,7 @@ class BigwheelController extends BaseAuthedController {
} }
break; break;
} }
}
return true; return true;
}); });
if (count($item1Hash) != count($item2Hash) || if (count($item1Hash) != count($item2Hash) ||
@ -141,7 +143,7 @@ class BigwheelController extends BaseAuthedController {
{ {
$rnd = rand(0, $randSpace1 - 1); $rnd = rand(0, $randSpace1 - 1);
foreach ($item1Arr as $item) { foreach ($item1Arr as $item) {
if ($item['weight'] <= $rnd) { if ($rnd <= $item['weight']) {
$item1 = $item; $item1 = $item;
break; break;
} }
@ -151,7 +153,7 @@ class BigwheelController extends BaseAuthedController {
{ {
$rnd = rand(0, $randSpace2 - 2); $rnd = rand(0, $randSpace2 - 2);
foreach ($item2Arr as $item) { foreach ($item2Arr as $item) {
if ($item['weight'] <= $rnd) { if ($rnd <= $item['weight']) {
$item2 = $item; $item2 = $item;
break; break;
} }