老虎机三项修复:①来源label已有枚举(刷新即显中文) ②普通中奖/诅咒向本人发私聊通知+三7全服广播 ③FAB按钮支持拖动+位置localStorage持久化
This commit is contained in:
@@ -146,6 +146,7 @@ class SlotMachineController extends Controller
|
||||
}
|
||||
|
||||
// ⑤ 写游戏日志
|
||||
$resultLabel = SlotMachineLog::resultLabel($resultType);
|
||||
SlotMachineLog::create([
|
||||
'user_id' => $user->id,
|
||||
'reel1' => $r1,
|
||||
@@ -156,9 +157,23 @@ class SlotMachineController extends Controller
|
||||
'payout' => $payout,
|
||||
]);
|
||||
|
||||
// ⑥ 三个7:全服公屏广播
|
||||
// ⑥ 广播通知
|
||||
$e1 = $symbols[$r1]['emoji'];
|
||||
$e2 = $symbols[$r2]['emoji'];
|
||||
$e3 = $symbols[$r3]['emoji'];
|
||||
|
||||
if ($resultType === 'jackpot') {
|
||||
// 三个7:全服公屏广播
|
||||
$this->broadcastJackpot($user->username, $payout, $cost);
|
||||
} elseif (in_array($resultType, ['triple_gem', 'triple', 'pair'], true)) {
|
||||
// 普通中奖:仅向本人发送聊天室系统通知
|
||||
$net = $payout - $cost;
|
||||
$content = "🎰 {$resultLabel}!{$e1}{$e2}{$e3} 赢得 +🪙".number_format($net).' 金币';
|
||||
$this->broadcastPersonal($user->username, $content);
|
||||
} elseif ($resultType === 'curse') {
|
||||
// 诅咒:通知本人
|
||||
$content = "☠️ 三骷髅诅咒!{$e1}{$e2}{$e3} 额外扣除 🪙".number_format($cost).' 金币!';
|
||||
$this->broadcastPersonal($user->username, $content);
|
||||
}
|
||||
|
||||
$user->refresh();
|
||||
@@ -246,4 +261,28 @@ class SlotMachineController extends Controller
|
||||
broadcast(new MessageSent(1, $msg));
|
||||
SaveMessageJob::dispatch($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向特定用户发送聊天室私人系统通知(仅该用户可见)。
|
||||
*
|
||||
* @param string $toUsername 接收用户名
|
||||
* @param string $content 消息内容
|
||||
*/
|
||||
private function broadcastPersonal(string $toUsername, string $content): void
|
||||
{
|
||||
$msg = [
|
||||
'id' => $this->chatState->nextMessageId(1),
|
||||
'room_id' => 1,
|
||||
'from_user' => '系统传音',
|
||||
'to_user' => $toUsername,
|
||||
'content' => $content,
|
||||
'is_secret' => true,
|
||||
'font_color' => '#f59e0b',
|
||||
'action' => '',
|
||||
'sent_at' => now()->toDateTimeString(),
|
||||
];
|
||||
|
||||
broadcast(new MessageSent(1, $msg));
|
||||
SaveMessageJob::dispatch($msg);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user