比赛观战开关

This commit is contained in:
sk 2024-08-22 13:49:33 +08:00
parent 71655d8126
commit 18e3e5cd7d
8 changed files with 100 additions and 28 deletions

View File

@ -853,3 +853,9 @@ const (
On = 1 // 开启
Off = 2 // 关闭
)
const (
DataConfigAll = 0 // 全部配置
DataConfigSprite = 1 // 精灵配置
DataConfigMatchAudience = 2 // 赛事观战开关
)

View File

@ -135,7 +135,7 @@ type AllConfig struct {
*webapi.AwardLogConfig
// 新手引导配置
*webapi.GuideConfig
MatchAudience map[int32]*webapi.MatchAudience // 比赛观众列表
MatchAudience map[int32]*webapi.MatchAudience // 比赛观众列表 key: 玩家id
// 小精灵配置
*webapi.SpiritConfig
}

View File

@ -10903,7 +10903,7 @@ type Config struct {
// Tp 类型:
// 1:小精灵快捷入口 On开关 Value地址
// 2: ...
// 2:比赛观战开关 On开关
// ...
Tp int32 `protobuf:"varint,1,opt,name=Tp,proto3" json:"Tp,omitempty"`
On bool `protobuf:"varint,2,opt,name=On,proto3" json:"On,omitempty"`

View File

@ -1351,7 +1351,7 @@ message SCGuideConfig{
message Config{
// Tp
// 1: On开关 Value地址
// 2: ...
// 2: On开关
// ...
int32 Tp = 1;
bool On = 2;

2
public

@ -1 +1 @@
Subproject commit 5436469c04056f83ab69b52b7cdeb5d21832fa94
Subproject commit e754bb123f44b0f524ec9dd6d67a1e9d2803a7c5

View File

@ -323,15 +323,7 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e
case *webapi.SpiritConfig:
PlatformMgrSingleton.GetConfig(config.Platform).SpiritConfig = config
if !isInit {
PlayerMgrSington.BroadcastMessageToPlatform(config.Platform, int(playerproto.PlayerPacketID_PACKET_SCDataConfig), &playerproto.SCDataConfig{
Cfg: []*playerproto.Config{
{
Tp: 1,
On: config.GetOn() == 1,
Value: config.GetUrl(),
},
},
})
PlayerMgrSington.BroadcastDataConfigToPlatform(config.Platform, common.DataConfigSprite)
}
default:
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
@ -404,8 +396,20 @@ func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *c
switch event.Type {
case clientv3.EventTypePut:
PlatformMgrSingleton.AddMatchAudience(config)
if !isInit {
p := PlayerMgrSington.GetPlayerBySnId(config.GetSnId())
if p != nil {
p.SCDataConfig(common.DataConfigMatchAudience)
}
}
case clientv3.EventTypeDelete:
PlatformMgrSingleton.DelMatchAudience(config)
if !isInit {
p := PlayerMgrSington.GetPlayerBySnId(config.GetSnId())
if p != nil {
p.SCDataConfig(common.DataConfigMatchAudience)
}
}
}
default:

View File

@ -3101,8 +3101,8 @@ func (this *Player) SendPlayerInfo() {
this.SCItems()
// 引导配置
this.SCGuide()
// 小精灵配置
this.SCSpirit()
// 其它配置
this.SCDataConfig(common.DataConfigAll)
}
//func (this *Player) SendJackpotInfo() {
@ -4951,20 +4951,66 @@ func (this *Player) SCGuide() {
logger.Logger.Tracef("SCGuideConfig: %v", pack)
}
func (this *Player) SCSpirit() {
cfg := PlatformMgrSingleton.GetConfig(this.Platform).SpiritConfig
if cfg == nil {
// DataConfigFuncMap 配置查询方法
var DataConfigFuncMap = map[int]func(platform string, p *Player) *playerproto.Config{
common.DataConfigSprite: func(platform string, p *Player) *playerproto.Config {
cfg := PlatformMgrSingleton.GetConfig(platform).SpiritConfig
if cfg == nil {
return nil
}
return &playerproto.Config{
Tp: common.DataConfigSprite,
On: cfg.On == 1,
Value: cfg.Url,
}
},
common.DataConfigMatchAudience: func(platform string, p *Player) *playerproto.Config {
if p == nil {
return nil
}
cfg := PlatformMgrSingleton.GetConfig(platform).MatchAudience
if cfg == nil {
return nil
}
d, ok := cfg[p.GetSnId()]
if !ok || d == nil {
return &playerproto.Config{
Tp: common.DataConfigMatchAudience,
On: false,
}
}
return &playerproto.Config{
Tp: common.DataConfigMatchAudience,
On: true,
}
},
}
// SCDataConfig 通知配置
// tp 类型 0所有 1小精灵 2比赛观众开关
func (this *Player) SCDataConfig(tp int) {
if this == nil {
return
}
pack := &playerproto.SCDataConfig{
Cfg: []*playerproto.Config{
{
Tp: 1,
On: cfg.On == 1,
Value: cfg.Url,
},
},
pack := &playerproto.SCDataConfig{}
if tp == common.DataConfigAll {
for _, f := range DataConfigFuncMap {
d := f(this.Platform, this)
if d != nil {
pack.Cfg = append(pack.Cfg, d)
}
}
} else {
f, ok := DataConfigFuncMap[tp]
if ok {
d := f(this.Platform, this)
if d != nil {
pack.Cfg = append(pack.Cfg, d)
}
}
}
if len(pack.Cfg) > 0 {
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SCDataConfig), pack)
logger.Logger.Tracef("SCDataConfig: %v", pack)
}
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SCDataConfig), pack)
logger.Logger.Tracef("SCDataConfig: %v", pack)
}

View File

@ -15,6 +15,7 @@ import (
"mongo.games.com/game/common"
"mongo.games.com/game/model"
"mongo.games.com/game/proto"
playerproto "mongo.games.com/game/protocol/player"
serverproto "mongo.games.com/game/protocol/server"
"mongo.games.com/game/worldsrv/internal"
)
@ -328,6 +329,21 @@ func (this *PlayerMgr) BroadcastMessageToPlatform(platform string, packetid int,
}
}
func (this *PlayerMgr) BroadcastDataConfigToPlatform(platform string, tp int) {
packetId := int(playerproto.PlayerPacketID_PACKET_SCDataConfig)
pack := &playerproto.SCDataConfig{}
f, ok := DataConfigFuncMap[tp]
if ok {
d := f(platform, nil)
if d != nil {
pack.Cfg = append(pack.Cfg, d)
}
}
if len(pack.Cfg) > 0 {
this.BroadcastMessageToPlatform(platform, packetId, pack)
}
}
func (this *PlayerMgr) BroadcastMessageToPlatformByFunc(platform string, packetid int, rawpack interface{}, f func(p *Player) bool) {
if platform == "" {
this.BroadcastMessage(packetid, rawpack)