Compare commits

...

2 Commits

Author SHA1 Message Date
sk d8a6246f93 竞技馆中奖广播 2024-10-29 10:11:33 +08:00
sk 0a67496d50 防止重复抽奖 2024-10-29 09:07:15 +08:00
9 changed files with 1272 additions and 1046 deletions

View File

@ -877,3 +877,7 @@ const (
LotteryStateRun = 2 // 抽奖进行中
LotteryStateNoStart = 3 // 抽奖未开始
)
const (
NoticeTypeCustomAward = 1 + iota // 房卡场获奖通知
)

View File

@ -16,6 +16,7 @@ import (
"mongo.games.com/game/model"
"mongo.games.com/game/mq"
"mongo.games.com/game/proto"
"mongo.games.com/game/protocol/server"
"mongo.games.com/game/protocol/tienlen"
"mongo.games.com/game/srvdata"
)
@ -2634,6 +2635,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
p := base.PlayerMgrSington.GetPlayerBySnId(packBilled.List[0].SnId)
if p != nil {
var items []*model.Item
var noticeItems []*server.Item
for _, v := range packBilled.List[0].Award {
itemData := srvdata.GameItemMgr.Get(p.Platform, v.GetId())
if itemData != nil {
@ -2641,6 +2643,10 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
ItemId: v.GetId(),
ItemNum: v.GetNum(),
})
noticeItems = append(noticeItems, &server.Item{
Id: v.GetId(),
Num: v.GetNum(),
})
}
}
p.AddItems(&model.AddItemParam{
@ -2667,6 +2673,16 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
mq.Write(award, mq.DBCustomLogAward)
mq.Write(award, mq.WorldCustomAward)
sceneEx.PlayerAward[p.SnId] = &items
notice := &server.GWNewNotice{
Platform: p.Platform,
Tp: common.NoticeTypeCustomAward,
RoomId: sceneEx.SceneId,
SnId: p.GetSnId(),
Name: p.GetName(),
RoleId: p.Roles.ModId,
Items: noticeItems,
}
sceneEx.SendToWorld(int(server.SSPacketID_PACKET_GW_NEWNOTICE), notice)
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,21 @@ enum MSGPacketID {
PACKET_SC_GETMESSAGEATTACH = 2437;
PACKET_SC_NOTICE = 2438;
PACKET_CS_MESSAGELIST = 2439;
PACKET_Notice = 2440; //
}
message Item {
int32 Id = 1;
int64 Num = 2;
}
// PACKET_Notice
message Notice {
int32 Tp = 1; // 1:
int32 SnId = 2;
string Name = 3;
int32 RoleId = 4;
repeated Item Items = 5;
}
message NoticeParam{

File diff suppressed because it is too large Load Diff

View File

@ -544,15 +544,13 @@ message WGHundredOp{
//广
message GWNewNotice{
string ch = 1;
string content = 2;
int64 start = 3;
int64 interval = 4;
int64 count = 5;
int64 msgtype = 6;
string platform = 7;
int32 priority = 8;
bool isrob = 9;
string Platform = 1; //
int32 Tp = 2; // 1
int32 RoomId = 3; //id
int32 SnId = 4; //id
string Name = 5; //
int32 RoleId = 6; //id
repeated Item Items = 7; //
}
message PlayerStatics{

View File

@ -1425,6 +1425,9 @@ func CSGetPrivateRoomListHandler(s *netlib.Session, packetId int, data interface
State: v.SceneState,
Players: players,
}
if v.creator == 0 {
d.IsSystem = true
}
pack.Datas = append(pack.Datas, d)
}

View File

@ -14,6 +14,7 @@ import (
"mongo.games.com/game/model"
"mongo.games.com/game/mq"
loginproto "mongo.games.com/game/protocol/login"
"mongo.games.com/game/protocol/message"
playerproto "mongo.games.com/game/protocol/player"
serverproto "mongo.games.com/game/protocol/server"
"mongo.games.com/game/srvdata"
@ -317,19 +318,41 @@ func init() {
}))
// 游戏服务器的系统广播
// 捕鱼
//netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_NEWNOTICE), netlib.PacketFactoryWrapper(func() interface{} {
// return &serverproto.GWNewNotice{}
//}))
//netlib.RegisterHandler(int(serverproto.SSPacketID_PACKET_GW_NEWNOTICE), netlib.HandlerWrapper(func(s *netlib.Session,
// packetid int, pack interface{}) error {
// logger.Logger.Trace("receive GWNewNotice:", pack)
// if msg, ok := pack.(*serverproto.GWNewNotice); ok {
// //立即发送改为定期发送,控制下广播包的频度
// //HorseRaceLampMgrSingleton.PushGameHorseRaceLamp(msg.GetCh(), msg.GetPlatform(), msg.GetContent(), int32(msg.GetMsgtype()), msg.GetIsrob(), msg.GetPriority())
// }
// return nil
//}))
netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_NEWNOTICE), netlib.PacketFactoryWrapper(func() interface{} {
return &serverproto.GWNewNotice{}
}))
netlib.RegisterHandler(int(serverproto.SSPacketID_PACKET_GW_NEWNOTICE), netlib.HandlerWrapper(func(s *netlib.Session, packetID int, pack interface{}) error {
logger.Logger.Tracef("receive SSPacketID_PACKET_GW_NEWNOTICE GWNewNotice:%v", pack)
msg, ok := pack.(*serverproto.GWNewNotice)
if !ok {
return nil
}
switch msg.GetTp() {
case common.NoticeTypeCustomAward:
var items []*message.Item
for _, v := range msg.GetItems() {
items = append(items, &message.Item{
Id: v.GetId(),
Num: v.GetNum(),
})
}
notice := &message.Notice{
Tp: msg.GetTp(),
SnId: msg.GetSnId(),
Name: msg.GetName(),
RoleId: msg.GetRoleId(),
Items: items,
}
PlayerMgrSington.BroadcastMessageToPlatform(msg.GetPlatform(), int(message.MSGPacketID_PACKET_Notice), notice)
logger.Logger.Tracef("broadcast custom award notice:%v", notice)
default:
logger.Logger.Errorf("not type GWNewNotice:%v", pack)
}
return nil
}))
// 强制离开房间
// 返回房间失败

View File

@ -53,6 +53,7 @@ func init() {
// LotteryData 抽奖数据
type LotteryData struct {
*model.LotteryData
isDone bool // 抽奖中
}
// Reset 重置抽奖数据
@ -287,6 +288,11 @@ func (l *LotteryData) Done() {
value, tp, index, l.RobotIndex, l.Code, l.PlayerIndex, l.CId)
}
if l.isDone {
return
}
l.isDone = true
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
// 查询参与人数
joinNum, err = model.GetLotteryCodeJoinNum(l.Platform, l.CId, l.StartTs)
@ -333,6 +339,9 @@ func (l *LotteryData) Done() {
}
return nil
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
defer func() {
l.isDone = false
}()
if code == nil && isMust {
code = &model.LotteryCode{
Platform: l.Platform,