优化会员显示
This commit is contained in:
@@ -496,12 +496,22 @@ class ChatController extends Controller
|
|||||||
if ($eventChance > 0 && rand(1, 100) <= $eventChance) {
|
if ($eventChance > 0 && rand(1, 100) <= $eventChance) {
|
||||||
$autoEvent = Autoact::randomEvent();
|
$autoEvent = Autoact::randomEvent();
|
||||||
if ($autoEvent) {
|
if ($autoEvent) {
|
||||||
|
// 计算会员倍率加成(仅正向奖励有效)
|
||||||
|
$expMul = $this->vipService->getExpMultiplier($user);
|
||||||
|
$jjbMul = $this->vipService->getJjbMultiplier($user);
|
||||||
|
|
||||||
|
$finalExp = $autoEvent->exp_change > 0 ? (int) round($autoEvent->exp_change * $expMul) : $autoEvent->exp_change;
|
||||||
|
$finalJjb = $autoEvent->jjb_change > 0 ? (int) round($autoEvent->jjb_change * $jjbMul) : $autoEvent->jjb_change;
|
||||||
|
|
||||||
|
$bonusExp = ($autoEvent->exp_change > 0 && $finalExp > $autoEvent->exp_change) ? $finalExp - $autoEvent->exp_change : 0;
|
||||||
|
$bonusJjb = ($autoEvent->jjb_change > 0 && $finalJjb > $autoEvent->jjb_change) ? $finalJjb - $autoEvent->jjb_change : 0;
|
||||||
|
|
||||||
// 经验变化:通过 UserCurrencyService 写日志
|
// 经验变化:通过 UserCurrencyService 写日志
|
||||||
if ($autoEvent->exp_change !== 0) {
|
if ($finalExp !== 0) {
|
||||||
$this->currencyService->change(
|
$this->currencyService->change(
|
||||||
$user,
|
$user,
|
||||||
'exp',
|
'exp',
|
||||||
$autoEvent->exp_change,
|
$finalExp,
|
||||||
CurrencySource::AUTO_EVENT,
|
CurrencySource::AUTO_EVENT,
|
||||||
"随机事件:{$autoEvent->text_body}",
|
"随机事件:{$autoEvent->text_body}",
|
||||||
$id,
|
$id,
|
||||||
@@ -509,11 +519,11 @@ class ChatController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 金币变化:通过 UserCurrencyService 写日志
|
// 金币变化:通过 UserCurrencyService 写日志
|
||||||
if ($autoEvent->jjb_change !== 0) {
|
if ($finalJjb !== 0) {
|
||||||
$this->currencyService->change(
|
$this->currencyService->change(
|
||||||
$user,
|
$user,
|
||||||
'gold',
|
'gold',
|
||||||
$autoEvent->jjb_change,
|
$finalJjb,
|
||||||
CurrencySource::AUTO_EVENT,
|
CurrencySource::AUTO_EVENT,
|
||||||
"随机事件:{$autoEvent->text_body}",
|
"随机事件:{$autoEvent->text_body}",
|
||||||
$id,
|
$id,
|
||||||
@@ -529,13 +539,27 @@ class ChatController extends Controller
|
|||||||
$user->save();
|
$user->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 构建会员额外加成文案(参考钓鱼系统,确保不弄错)
|
||||||
|
$bonusParts = [];
|
||||||
|
if ($bonusExp > 0) {
|
||||||
|
$bonusParts[] = "+经验{$bonusExp}";
|
||||||
|
}
|
||||||
|
if ($bonusJjb > 0) {
|
||||||
|
$bonusParts[] = "+金币{$bonusJjb}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$eventContent = $autoEvent->renderText($user->username);
|
||||||
|
if (! empty($bonusParts)) {
|
||||||
|
$eventContent .= '('.$user->vipName().'追加:'.implode(',', $bonusParts).')';
|
||||||
|
}
|
||||||
|
|
||||||
// 广播随机事件消息到聊天室
|
// 广播随机事件消息到聊天室
|
||||||
$eventMsg = [
|
$eventMsg = [
|
||||||
'id' => $this->chatState->nextMessageId($id),
|
'id' => $this->chatState->nextMessageId($id),
|
||||||
'room_id' => $id,
|
'room_id' => $id,
|
||||||
'from_user' => '星海小博士',
|
'from_user' => '星海小博士',
|
||||||
'to_user' => '大家',
|
'to_user' => '大家',
|
||||||
'content' => $autoEvent->renderText($user->username),
|
'content' => $eventContent,
|
||||||
'is_secret' => false,
|
'is_secret' => false,
|
||||||
'font_color' => match ($autoEvent->event_type) {
|
'font_color' => match ($autoEvent->event_type) {
|
||||||
'good' => '#16a34a', // 绿色(好运)
|
'good' => '#16a34a', // 绿色(好运)
|
||||||
|
|||||||
Reference in New Issue
Block a user