临时加-限制特定用户抽中巡乐会主奖品-调试

This commit is contained in:
2025-12-20 20:18:02 +08:00
parent 4b5eb28781
commit c68bb44650

View File

@@ -1352,11 +1352,6 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
*/
private function adjustGiftProbabilities(array $gifts, $user_id = 0)
{
// 如果没有指定用户或该用户没有特殊概率调整,则直接返回原数组
if ($user_id <= 0 || !isset($probability_adjustments[$user_id])) {
return $gifts;
}
$ext = $this->getCachedGiftBag(13); //获取转盘信息
$selected_gift_id = $ext['locking_condition']['selected_gift_id'];
// 定义需要降低概率的用户和礼物组合
@@ -1367,13 +1362,18 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
// 1001 => [2001 => 0.5],
//测试数据
20060 => [$selected_gift_id => 0.1],
20060 => [$selected_gift_id => 2],
// 在这里可以添加更多规则 【正式规则】
// 21222 => [$selected_gift_id => 0.3],
// 21259 => [$selected_gift_id => 0.3],
21222 => [$selected_gift_id => 6],
21259 => [$selected_gift_id => 6],
];
// 如果没有指定用户或该用户没有特殊概率调整,则直接返回原数组
if ($user_id <= 0 || !isset($probability_adjustments[$user_id])) {
return $gifts;
}
$adjusted_gifts = [];
foreach ($gifts as $gift) {
$adjusted_gift = $gift;
@@ -1381,7 +1381,15 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
if (isset($probability_adjustments[$user_id][$gift['foreign_id']])) {
// 降低该礼物的剩余数量权重(相当于降低被抽中的概率)
$reduction_factor = $probability_adjustments[$user_id][$gift['foreign_id']];
$adjusted_gift['remaining_number'] = max(1, intval($gift['remaining_number'] * $reduction_factor));
// $adjusted_gift['remaining_number'] = max(1, intval($gift['remaining_number'] * $reduction_factor));
//从数组中随机取出一个数
//概率数组
$pros[0] = 1;
for ($i = 1; $i <= $reduction_factor; $i++) {
$pros[$i] = 0;
}
$prosandomKey = array_rand($pros);
$adjusted_gift['remaining_number'] = $pros[$prosandomKey];
}
$adjusted_gifts[] = $adjusted_gift;
}