1.优化抽奖券的抽奖逻辑
This commit is contained in:
@@ -118,7 +118,8 @@ class PlayStartLogic
|
||||
}
|
||||
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->where('dept_id', $configDeptId)->find();
|
||||
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->where('dept_id', $configDeptId)->find();
|
||||
$configKill = DiceLotteryPoolConfig::where('name', 'killScore')->where('dept_id', $configDeptId)->find();
|
||||
$configFree = DiceLotteryPoolConfig::where('name', 'free')->where('dept_id', $configDeptId)->find();
|
||||
if (!$configType0) {
|
||||
throw new ApiException('Lottery pool config not found (name=default required)');
|
||||
}
|
||||
@@ -132,17 +133,28 @@ class PlayStartLogic
|
||||
}
|
||||
|
||||
// 彩金池累计盈利:用于判断是否触发杀分(不再依赖单个玩家累计盈利)
|
||||
// 该值来自 dice_lottery_pool_config.profit_amount
|
||||
// 该值来自 dice_lottery_pool_config.profit_amount(default 奖池)
|
||||
$poolProfitTotal = $configType0->profit_amount ?? 0;
|
||||
$safetyLine = (int) ($configType0->safety_line ?? 0);
|
||||
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
|
||||
// 盈利>=安全线且开启杀分:付费/免费都用 killScore;盈利<安全线:付费用玩家权重,免费用 killScore(无则用 default)
|
||||
// 记录 lottery_config_id:用池权重时记对应池,付费用玩家权重时记 default
|
||||
$usePoolWeights = ($ticketType === self::LOTTERY_TYPE_PAID && $killEnabled && $poolProfitTotal >= $safetyLine && $configType1 !== null)
|
||||
|| ($ticketType === self::LOTTERY_TYPE_FREE);
|
||||
$config = $usePoolWeights
|
||||
? (($ticketType === self::LOTTERY_TYPE_FREE && $configType1 === null) ? $configType0 : $configType1)
|
||||
: $configType0;
|
||||
|
||||
$usePaidKill = $ticketType === self::LOTTERY_TYPE_PAID
|
||||
&& $killEnabled
|
||||
&& $poolProfitTotal >= $safetyLine
|
||||
&& $configKill !== null;
|
||||
|
||||
if ($ticketType === self::LOTTERY_TYPE_FREE) {
|
||||
// 免费抽奖券:使用本渠道 name=free 奖池档位权重;无 free 时回退 default
|
||||
$config = $configFree ?? $configType0;
|
||||
$usePoolWeights = true;
|
||||
} elseif ($usePaidKill) {
|
||||
$config = $configKill;
|
||||
$usePoolWeights = true;
|
||||
} else {
|
||||
// 付费未触发杀分:按玩家 T*_weight 抽档,lottery_config_id 记 default
|
||||
$config = $configType0;
|
||||
$usePoolWeights = false;
|
||||
}
|
||||
|
||||
// 按档位 T1-T5 抽取后,从 DiceReward 表按当前方向取该档位数据,再按 weight 抽取一条得到 grid_number
|
||||
$rewardInstance = DiceReward::getCachedInstance($configDeptId);
|
||||
|
||||
Reference in New Issue
Block a user