比赛观战开关
This commit is contained in:
parent
71655d8126
commit
18e3e5cd7d
|
@ -853,3 +853,9 @@ const (
|
||||||
On = 1 // 开启
|
On = 1 // 开启
|
||||||
Off = 2 // 关闭
|
Off = 2 // 关闭
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DataConfigAll = 0 // 全部配置
|
||||||
|
DataConfigSprite = 1 // 精灵配置
|
||||||
|
DataConfigMatchAudience = 2 // 赛事观战开关
|
||||||
|
)
|
||||||
|
|
|
@ -135,7 +135,7 @@ type AllConfig struct {
|
||||||
*webapi.AwardLogConfig
|
*webapi.AwardLogConfig
|
||||||
// 新手引导配置
|
// 新手引导配置
|
||||||
*webapi.GuideConfig
|
*webapi.GuideConfig
|
||||||
MatchAudience map[int32]*webapi.MatchAudience // 比赛观众列表
|
MatchAudience map[int32]*webapi.MatchAudience // 比赛观众列表 key: 玩家id
|
||||||
// 小精灵配置
|
// 小精灵配置
|
||||||
*webapi.SpiritConfig
|
*webapi.SpiritConfig
|
||||||
}
|
}
|
||||||
|
|
|
@ -10903,7 +10903,7 @@ type Config struct {
|
||||||
|
|
||||||
// Tp 类型:
|
// Tp 类型:
|
||||||
// 1:小精灵快捷入口 On开关 Value地址
|
// 1:小精灵快捷入口 On开关 Value地址
|
||||||
// 2: ...
|
// 2:比赛观战开关 On开关
|
||||||
// ...
|
// ...
|
||||||
Tp int32 `protobuf:"varint,1,opt,name=Tp,proto3" json:"Tp,omitempty"`
|
Tp int32 `protobuf:"varint,1,opt,name=Tp,proto3" json:"Tp,omitempty"`
|
||||||
On bool `protobuf:"varint,2,opt,name=On,proto3" json:"On,omitempty"`
|
On bool `protobuf:"varint,2,opt,name=On,proto3" json:"On,omitempty"`
|
||||||
|
|
|
@ -1351,7 +1351,7 @@ message SCGuideConfig{
|
||||||
message Config{
|
message Config{
|
||||||
// Tp 类型:
|
// Tp 类型:
|
||||||
// 1:小精灵快捷入口 On开关 Value地址
|
// 1:小精灵快捷入口 On开关 Value地址
|
||||||
// 2: ...
|
// 2:比赛观战开关 On开关
|
||||||
// ...
|
// ...
|
||||||
int32 Tp = 1;
|
int32 Tp = 1;
|
||||||
bool On = 2;
|
bool On = 2;
|
||||||
|
|
2
public
2
public
|
@ -1 +1 @@
|
||||||
Subproject commit 5436469c04056f83ab69b52b7cdeb5d21832fa94
|
Subproject commit e754bb123f44b0f524ec9dd6d67a1e9d2803a7c5
|
|
@ -323,15 +323,7 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e
|
||||||
case *webapi.SpiritConfig:
|
case *webapi.SpiritConfig:
|
||||||
PlatformMgrSingleton.GetConfig(config.Platform).SpiritConfig = config
|
PlatformMgrSingleton.GetConfig(config.Platform).SpiritConfig = config
|
||||||
if !isInit {
|
if !isInit {
|
||||||
PlayerMgrSington.BroadcastMessageToPlatform(config.Platform, int(playerproto.PlayerPacketID_PACKET_SCDataConfig), &playerproto.SCDataConfig{
|
PlayerMgrSington.BroadcastDataConfigToPlatform(config.Platform, common.DataConfigSprite)
|
||||||
Cfg: []*playerproto.Config{
|
|
||||||
{
|
|
||||||
Tp: 1,
|
|
||||||
On: config.GetOn() == 1,
|
|
||||||
Value: config.GetUrl(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
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 {
|
switch event.Type {
|
||||||
case clientv3.EventTypePut:
|
case clientv3.EventTypePut:
|
||||||
PlatformMgrSingleton.AddMatchAudience(config)
|
PlatformMgrSingleton.AddMatchAudience(config)
|
||||||
|
if !isInit {
|
||||||
|
p := PlayerMgrSington.GetPlayerBySnId(config.GetSnId())
|
||||||
|
if p != nil {
|
||||||
|
p.SCDataConfig(common.DataConfigMatchAudience)
|
||||||
|
}
|
||||||
|
}
|
||||||
case clientv3.EventTypeDelete:
|
case clientv3.EventTypeDelete:
|
||||||
PlatformMgrSingleton.DelMatchAudience(config)
|
PlatformMgrSingleton.DelMatchAudience(config)
|
||||||
|
if !isInit {
|
||||||
|
p := PlayerMgrSington.GetPlayerBySnId(config.GetSnId())
|
||||||
|
if p != nil {
|
||||||
|
p.SCDataConfig(common.DataConfigMatchAudience)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -3101,8 +3101,8 @@ func (this *Player) SendPlayerInfo() {
|
||||||
this.SCItems()
|
this.SCItems()
|
||||||
// 引导配置
|
// 引导配置
|
||||||
this.SCGuide()
|
this.SCGuide()
|
||||||
// 小精灵配置
|
// 其它配置
|
||||||
this.SCSpirit()
|
this.SCDataConfig(common.DataConfigAll)
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (this *Player) SendJackpotInfo() {
|
//func (this *Player) SendJackpotInfo() {
|
||||||
|
@ -4951,20 +4951,66 @@ func (this *Player) SCGuide() {
|
||||||
logger.Logger.Tracef("SCGuideConfig: %v", pack)
|
logger.Logger.Tracef("SCGuideConfig: %v", pack)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Player) SCSpirit() {
|
// DataConfigFuncMap 配置查询方法
|
||||||
cfg := PlatformMgrSingleton.GetConfig(this.Platform).SpiritConfig
|
var DataConfigFuncMap = map[int]func(platform string, p *Player) *playerproto.Config{
|
||||||
if cfg == nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
pack := &playerproto.SCDataConfig{
|
pack := &playerproto.SCDataConfig{}
|
||||||
Cfg: []*playerproto.Config{
|
if tp == common.DataConfigAll {
|
||||||
{
|
for _, f := range DataConfigFuncMap {
|
||||||
Tp: 1,
|
d := f(this.Platform, this)
|
||||||
On: cfg.On == 1,
|
if d != nil {
|
||||||
Value: cfg.Url,
|
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)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
|
playerproto "mongo.games.com/game/protocol/player"
|
||||||
serverproto "mongo.games.com/game/protocol/server"
|
serverproto "mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/game/worldsrv/internal"
|
"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) {
|
func (this *PlayerMgr) BroadcastMessageToPlatformByFunc(platform string, packetid int, rawpack interface{}, f func(p *Player) bool) {
|
||||||
if platform == "" {
|
if platform == "" {
|
||||||
this.BroadcastMessage(packetid, rawpack)
|
this.BroadcastMessage(packetid, rawpack)
|
||||||
|
|
Loading…
Reference in New Issue