128 lines
3.4 KiB
Go
Raw Normal View History

2025-06-08 00:52:17 +08:00
package room
2025-06-10 22:29:29 +08:00
import (
"game/common/baseroom"
"game/common/proto/pb"
)
2025-06-09 19:10:18 +08:00
func (rm *ColorRoom) notifyGameStart() {
ntf := &pb.NtfColorGameStart{
EndTime: rm.endTimeStatus(),
2025-06-09 23:52:18 +08:00
Jackpot: rm.jackpotValue,
2025-06-09 19:10:18 +08:00
}
rm.Broadcast(pb.MsgId_NtfColorGameStartId, ntf)
}
func (rm *ColorRoom) notifyBetting() {
ntf := &pb.NtfColorBetting{EndTime: rm.endTimeStatus()}
rm.Broadcast(pb.MsgId_NtfColorBettingId, ntf)
}
func (rm *ColorRoom) notifyEndBetting() {
ntf := &pb.NtfColorEndBetting{
EndTime: rm.endTimeStatus(),
AreaMul: rm.endBetAreaMul,
2025-06-09 23:52:18 +08:00
Jackpot: rm.jackpotValue,
2025-06-09 19:10:18 +08:00
}
rm.Broadcast(pb.MsgId_NtfColorEndBettingId, ntf)
2025-06-10 22:29:29 +08:00
rm.notifyBigUsers()
2025-06-09 19:10:18 +08:00
}
func (rm *ColorRoom) notifyOpenThreeDice() {
2025-06-10 22:29:29 +08:00
rm.Broadcast(pb.MsgId_NtfColorOpenThreeDiceId, rm.ntfOpenThreeDice)
2025-06-09 19:10:18 +08:00
}
func (rm *ColorRoom) notifySettle() {
2025-06-10 22:29:29 +08:00
rm.RangePlayer(func(u baseroom.IPlayer) bool {
user := GetPlayer(u)
rm.SendMsg(user, pb.MsgId_NtfColorSettleId, user.settleMsg)
return true
})
rm.notifyBigUsers()
}
func (rm *ColorRoom) notifyBigUsers() {
rm.Broadcast(pb.MsgId_NtfColorBigUserId, &pb.NtfColorBigUser{BigUser: rm.bigUsers})
}
func (rm *ColorRoom) notifyTrend() {
rm.Broadcast(pb.MsgId_NtfColorTrendId, rm.getNotifyTrend())
2025-06-09 19:10:18 +08:00
}
// 每秒更新各投注区域投注信息
func (rm *ColorRoom) notifyColorBetAreaInfo() {
rm.RangePlayer(func(u baseroom.IPlayer) bool {
user := GetPlayer(u)
for _, areaInfo := range rm.betAreaInfo {
areaInfo.MyBet = user.totalBets[areaInfo.Area]
}
rm.SendMsg(user, pb.MsgId_NtfColorBetAreaInfoId, &pb.NtfColorBetAreaInfo{
AreaInfos: rm.betAreaInfo,
})
return true
})
}
// 每秒更新各投注区域投注信息
func (rm *ColorRoom) notifyKickoutUser(user *ColorPlayer, code pb.ErrCode) {
rm.SendMsg(user, pb.MsgId_NtfKickOutUserId, &pb.NtfKickOutUser{Code: code})
}
2025-06-15 00:00:24 +08:00
// 每秒更新各投注区域投注信息
func (rm *ColorRoom) notifyPayoutFail(user *ColorPlayer, code pb.ErrCode) {
rm.SendMsg(user, pb.MsgId_NtfPayoutFailId, &pb.NtfPayoutFail{Code: code})
}
// 推送房间信息给玩家
func (rm *ColorRoom) notifyColorRoomInfo(user *ColorPlayer) {
ntf := &pb.NtfColorRoomInfo{
Status: rm.status,
EndTime: rm.endTimeStatus(),
Config: rm.getUserRoomConfig(user),
User: rm.getProtoUser(user),
WaitStart: nil,
Start: nil,
Betting: nil,
EndBet: nil,
OpenThreeDice: nil,
Settle: nil,
}
switch rm.status {
case pb.ColorGameStatus_CGS_WaitStart:
ntf.WaitStart = &pb.ColorRoomWaitStart{Trends: rm.getNotifyTrend()}
case pb.ColorGameStatus_CGS_Start:
ntf.Start = &pb.ColorRoomStart{
Trends: rm.getNotifyTrend(),
Start: &pb.NtfColorGameStart{
EndTime: rm.endTimeStatus(),
Jackpot: rm.jackpotValue,
},
}
case pb.ColorGameStatus_CGS_Betting:
ntf.Betting = &pb.ColorRoomBetting{
BetAreaInfo: &pb.NtfColorBetAreaInfo{
AreaInfos: rm.betAreaInfo,
},
}
case pb.ColorGameStatus_CGS_BetEnd:
ntf.EndBet = &pb.ColorRoomEndBet{
AreaMul: &pb.NtfColorEndBetting{
EndTime: rm.endTimeStatus(),
Jackpot: rm.jackpotValue,
AreaMul: rm.endBetAreaMul,
},
BetAreaInfo: &pb.NtfColorBetAreaInfo{
AreaInfos: rm.betAreaInfo,
},
BigUser: &pb.NtfColorBigUser{BigUser: rm.bigUsers},
}
case pb.ColorGameStatus_CGS_OpenThreeDice:
ntf.OpenThreeDice = &pb.ColorRoomOpenThreeDice{Dices: rm.ntfOpenThreeDice}
case pb.ColorGameStatus_CGS_Settle:
ntf.Settle = &pb.ColorRoomSettle{
Settle: user.settleMsg,
}
}
rm.SendMsg(user, pb.MsgId_NtfColorRoomInfoId, ntf)
}