优化一键测试权重

This commit is contained in:
2026-03-13 15:47:12 +08:00
parent f5eaf8da30
commit 0b26afde70
19 changed files with 991 additions and 274 deletions

View File

@@ -114,6 +114,20 @@ class LotteryService
return self::drawTierByWeightArray($tiers, $weights);
}
/**
* 根据 T1-T5 权重数组抽取档位(用于测试自定义档位概率)
* @param array $tierWeights 如 ['T1'=>100, 'T2'=>200, ...] 或 [100,200,300,400,500]
*/
public static function drawTierByWeightsFromArray(array $tierWeights): string
{
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
$weights = [];
foreach ($tiers as $i => $t) {
$weights[] = (int) ($tierWeights[$t] ?? $tierWeights[$i] ?? 0);
}
return self::drawTierByWeightArray($tiers, $weights);
}
/** 按档位权重数组抽取 T1-T5 */
private static function drawTierByWeightArray(array $tiers, array $weights): string
{