新增百家乐游戏:①数据库表+模型 ②OpenBaccaratRoundJob开局(广播+公屏) ③CloseBaccaratRoundJob结算(摇骰+赔付+CAS防并发) ④BaccaratController下注接口 ⑤前端弹窗(倒计时/骰子动画/历史趋势) ⑥调度器每分钟检查开局 ⑦GameConfig管控开关
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:百家乐结算广播事件
|
||||
*
|
||||
* 开奖后广播骰子结果和获奖类型,前端播放骰子动画,
|
||||
* 并显示用户是否中奖及赔付金额。
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\BaccaratRound;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class BaccaratRoundSettled implements ShouldBroadcastNow
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @param BaccaratRound $round 已结算的局次
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly BaccaratRound $round,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 广播至房间公共频道。
|
||||
*
|
||||
* @return array<Channel>
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [new Channel('room.1')];
|
||||
}
|
||||
|
||||
/**
|
||||
* 广播事件名(前端监听 .baccarat.settled)。
|
||||
*/
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'baccarat.settled';
|
||||
}
|
||||
|
||||
/**
|
||||
* 广播数据:骰子点数 + 开奖结果 + 统计。
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'round_id' => $this->round->id,
|
||||
'dice' => [$this->round->dice1, $this->round->dice2, $this->round->dice3],
|
||||
'total_points' => $this->round->total_points,
|
||||
'result' => $this->round->result,
|
||||
'result_label' => $this->round->resultLabel(),
|
||||
'total_payout' => $this->round->total_payout,
|
||||
'bet_count' => $this->round->bet_count,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user