优化杀分逻辑

This commit is contained in:
2026-03-17 15:36:14 +08:00
parent 1892c7bcb7
commit 150d31eac5
9 changed files with 38 additions and 37 deletions

View File

@@ -75,10 +75,6 @@ class PlayStartLogic
if (!$configType0) {
throw new ApiException('奖池配置不存在(需 type=0');
}
// 杀分时使用 type=1 配置的权重;未杀分时付费用 type=0、免费用 type=1无 type=1 时回退 type=0
$configForWeights = $ticketType === self::LOTTERY_TYPE_PAID
? $configType0
: ($configType1 ?? $configType0);
// 玩家累计盈利:仅统计 lottery_config_id=type=0 的成功对局(中奖金额-100*局数)
$playerQuery = DicePlayRecord::where('player_id', $playerId)
@@ -88,13 +84,11 @@ class PlayStartLogic
$playerPlayCount = (int) $playerQuery->count();
$playerProfitTotal = $playerWinSum - 100.0 * $playerPlayCount;
$safetyLine = (int) ($configType0->safety_line ?? 0);
// 玩家累计盈利>=安全线时杀分:用 type=1 的 T*_weight并记录 lottery_config_id=type=1 的 id否则用玩家权重记录对应配置 id
$usePoolWeights = $playerProfitTotal >= $safetyLine && $configType1 !== null;
if ($usePoolWeights) {
$config = $configType1;
} else {
$config = $configForWeights;
}
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
// 玩家累计盈利>=安全线时杀分:无论付费/免费,都用 type=1 的 T*_weight未达到时一律按玩家权重
// 记录 lottery_config_id杀分记 type=1未杀分统一记当前池 type=0
$usePoolWeights = $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null;
$config = $usePoolWeights ? $configType1 : $configType0;
// 按档位 T1-T5 抽取后,从 DiceReward 表按当前方向取该档位数据,再按 weight 抽取一条得到 grid_number
$rewardInstance = DiceReward::getCachedInstance();