盲盒转盘优化-重构-调试

This commit is contained in:
2025-10-29 09:02:20 +08:00
parent 50ed633439
commit 47e02d8796

View File

@@ -392,6 +392,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
*/
private function buildAliasTable($gifts)
{
print_r($gifts);die;
$n = count($gifts);
if ($n === 0) return null;
@@ -407,6 +408,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
// 归一化概率并填充索引映射
foreach ($gifts as $i => $gift) {
if ($gift['remaining_number'] <= 0) continue;
$indexMap[$i] = $gift;
$prob[$i] = $gift['remaining_number'] * $n / $totalRemaining;
if ($prob[$i] < 1.0) {