道具掉落添加渠道开关

This commit is contained in:
sk 2024-05-10 16:38:10 +08:00
parent 32fab5e0ca
commit f45708a8cc
14 changed files with 92 additions and 44 deletions

View File

@ -796,3 +796,8 @@ var PetIDs = []int32{PetIDChicken}
const (
InviteScoreRecharge = 10000 // 用户每充值$1邀请人获得积分
)
const (
ChannelSwitchExchange = 1
ChannelSwitchDropItem = 2
)

View File

@ -53,5 +53,5 @@ const (
ETCDKEY_PLAYERPOOL = "/game/plt/playerpool/" // 个人水池调控配置
ETCDKEY_GAME_CONFIG = "/game/plt/gameconfig/" // 游戏管理/全局配置
ETCDKEY_ACT_PHONELOTTERY = "/game/act_phoneLottery"
ETCDKEY_EXCHANGECHANNEL = "/game/exchange/channel" // 开启兑换功能的渠道
ETCDKEY_ChannelSwitch = "/game/channel/switch" // 渠道开关
)

View File

@ -163,6 +163,7 @@ func init() {
p.LastSyncCoin = p.Coin
p.IsQM = IsQM
p.AppChannel = msg.GetAppChannel()
if sid == 0 && (scene != nil && !scene.IsMatchScene()) {
logger.Logger.Warnf("when WGPlayerEnter (sid == 0)")
@ -306,6 +307,7 @@ func init() {
p.SetTakeCoin(msg.GetTakeCoin())
p.LastSyncCoin = p.Coin
p.IsQM = IsQM
p.AppChannel = msg.GetAppChannel()
if scene != nil {
scene.AudienceEnter(p, isload)
if !p.IsRobot() && !scene.Testing {

View File

@ -20,6 +20,8 @@ func init() {
etcd.Register(etcd.ETCDKEY_GAME_CONFIG, webapi.GameConfig{}, platformConfigEtcd)
// 集卡活动
etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, platformConfigEtcd)
// 渠道开关
etcd.Register(etcd.ETCDKEY_ChannelSwitch, webapi.ChannelSwitchConfig{}, platformConfigEtcd)
}
func platformConfigEtcd(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
@ -33,6 +35,8 @@ func platformConfigEtcd(ctx context.Context, completeKey string, isInit bool, ev
ConfigMgrInst.GetConfig(d.Platform).GameConfig = d
case *webapi.WelfareCollectConfig:
ConfigMgrInst.GetConfig(d.Platform).WelfareCollectConfig = d
case *webapi.ChannelSwitchConfig:
ConfigMgrInst.GetConfig(d.Platform).ChannelSwitch[d.GetTp()] = d
default:
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
}

View File

@ -122,6 +122,7 @@ type Player struct {
MatchRobotGrades []MatchRobotGrade
TestLog []string // 调试日志
RankScore map[int32]int64 // 段位积分
AppChannel string // app渠道(玩家本次登录使用的包的渠道类型,换登录包,这个值也会变;玩家model.PlayerData存储的渠道是玩家第一次登录的渠道不会修改)
}
type MatchRobotGrade struct {

View File

@ -2119,6 +2119,13 @@ func (this *Scene) TryBillExGameDrop(p *Player) {
if baseScore == 0 {
return
}
// 渠道开关
conf := ConfigMgrInst.GetConfig(p.Platform).ChannelSwitch[common.ChannelSwitchDropItem]
if conf == nil || !common.InSliceString(conf.OnChannelName, p.AppChannel) {
return
}
dropInfo := srvdata.GameDropMgrSingleton.GetDropInfoByBaseScore(int32(this.GameId), baseScore)
if dropInfo != nil && len(dropInfo) != 0 && p.Items != nil {
realDrop := make(map[int32]int32)

View File

@ -115,8 +115,8 @@ type AllConfig struct {
*webapi.ExchangeShopList
// 商店
ShopInfos map[int32]*ShopInfo // 商品id:商品信息
// 开启兑换的渠道
*webapi.ExchangeChannelConfig
// 渠道开关
ChannelSwitch map[int32]*webapi.ChannelSwitchConfig
}
type GlobalConfig struct {
@ -142,7 +142,8 @@ func (cm *ConfigMgr) GetConfig(platform string) *AllConfig {
if !ok {
c = &AllConfig{
// todo 初始化默认值
ShopInfos: make(map[int32]*ShopInfo),
ShopInfos: make(map[int32]*ShopInfo),
ChannelSwitch: make(map[int32]*webapi.ChannelSwitchConfig),
}
cm.platform[platform] = c
}

View File

@ -1304,6 +1304,7 @@ type WGPlayerEnter struct {
Items map[int32]int64 `protobuf:"bytes,17,rep,name=Items,proto3" json:"Items,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
MatchParams []int32 `protobuf:"varint,18,rep,packed,name=MatchParams,proto3" json:"MatchParams,omitempty"` //比赛参数
RankScore map[int32]int64 `protobuf:"bytes,19,rep,name=RankScore,proto3" json:"RankScore,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 排位积分
AppChannel string `protobuf:"bytes,20,opt,name=AppChannel,proto3" json:"AppChannel,omitempty"` // 包渠道
}
func (x *WGPlayerEnter) Reset() {
@ -1471,6 +1472,13 @@ func (x *WGPlayerEnter) GetRankScore() map[int32]int64 {
return nil
}
func (x *WGPlayerEnter) GetAppChannel() string {
if x != nil {
return x.AppChannel
}
return ""
}
//从观众席坐到座位
//PACKET_WG_AUDIENCESIT
type WGAudienceSit struct {
@ -8703,7 +8711,7 @@ var file_server_proto_rawDesc = []byte{
0x52, 0x0c, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x24,
0x0a, 0x0d, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x43, 0x66, 0x67, 0x18,
0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d,
0x65, 0x43, 0x66, 0x67, 0x22, 0xa3, 0x06, 0x0a, 0x0d, 0x57, 0x47, 0x50, 0x6c, 0x61, 0x79, 0x65,
0x65, 0x43, 0x66, 0x67, 0x22, 0xc3, 0x06, 0x0a, 0x0d, 0x57, 0x47, 0x50, 0x6c, 0x61, 0x79, 0x65,
0x72, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x03, 0x52, 0x03, 0x53, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x47, 0x61, 0x74, 0x65,
0x53, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x47, 0x61, 0x74, 0x65, 0x53,
@ -8746,7 +8754,9 @@ var file_server_proto_rawDesc = []byte{
0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x57, 0x47, 0x50, 0x6c, 0x61,
0x79, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x61, 0x6e, 0x6b, 0x53, 0x63, 0x6f,
0x72, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x52, 0x61, 0x6e, 0x6b, 0x53, 0x63, 0x6f,
0x72, 0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x72, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x41, 0x70, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c,
0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x41, 0x70, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x6e,
0x65, 0x6c, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e,

View File

@ -228,6 +228,7 @@ message WGPlayerEnter {
map<int32, int64> Items = 17;
repeated int32 MatchParams = 18;//
map<int32, int64> RankScore = 19;//
string AppChannel = 20; //
}
//

View File

@ -5701,18 +5701,19 @@ func (x *WelfareCollectConfig) GetSwitch() int32 {
return 0
}
// etcd /game/exchange/channel
type ExchangeChannelConfig struct {
// etcd /game/channel/switch
type ChannelSwitchConfig struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Platform string `protobuf:"bytes,1,opt,name=Platform,proto3" json:"Platform,omitempty"`
OnChannelName []string `protobuf:"bytes,2,rep,name=OnChannelName,proto3" json:"OnChannelName,omitempty"` // 开启渠道
Tp int32 `protobuf:"varint,1,opt,name=Tp,proto3" json:"Tp,omitempty"` // 开关类型 1.兑换 2.道具掉落
Platform string `protobuf:"bytes,2,opt,name=Platform,proto3" json:"Platform,omitempty"` // 平台id
OnChannelName []string `protobuf:"bytes,3,rep,name=OnChannelName,proto3" json:"OnChannelName,omitempty"` // 开启渠道
}
func (x *ExchangeChannelConfig) Reset() {
*x = ExchangeChannelConfig{}
func (x *ChannelSwitchConfig) Reset() {
*x = ChannelSwitchConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_common_proto_msgTypes[55]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -5720,13 +5721,13 @@ func (x *ExchangeChannelConfig) Reset() {
}
}
func (x *ExchangeChannelConfig) String() string {
func (x *ChannelSwitchConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ExchangeChannelConfig) ProtoMessage() {}
func (*ChannelSwitchConfig) ProtoMessage() {}
func (x *ExchangeChannelConfig) ProtoReflect() protoreflect.Message {
func (x *ChannelSwitchConfig) ProtoReflect() protoreflect.Message {
mi := &file_common_proto_msgTypes[55]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -5738,19 +5739,26 @@ func (x *ExchangeChannelConfig) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use ExchangeChannelConfig.ProtoReflect.Descriptor instead.
func (*ExchangeChannelConfig) Descriptor() ([]byte, []int) {
// Deprecated: Use ChannelSwitchConfig.ProtoReflect.Descriptor instead.
func (*ChannelSwitchConfig) Descriptor() ([]byte, []int) {
return file_common_proto_rawDescGZIP(), []int{55}
}
func (x *ExchangeChannelConfig) GetPlatform() string {
func (x *ChannelSwitchConfig) GetTp() int32 {
if x != nil {
return x.Tp
}
return 0
}
func (x *ChannelSwitchConfig) GetPlatform() string {
if x != nil {
return x.Platform
}
return ""
}
func (x *ExchangeChannelConfig) GetOnChannelName() []string {
func (x *ChannelSwitchConfig) GetOnChannelName() []string {
if x != nil {
return x.OnChannelName
}
@ -6684,16 +6692,17 @@ var file_common_proto_rawDesc = []byte{
0x63, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74,
0x66, 0x6f, 0x72, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74,
0x66, 0x6f, 0x72, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x18, 0x02,
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x22, 0x59, 0x0a, 0x15,
0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x43,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72,
0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72,
0x6d, 0x12, 0x24, 0x0a, 0x0d, 0x4f, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61,
0x6d, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x4f, 0x6e, 0x43, 0x68, 0x61, 0x6e,
0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x26, 0x5a, 0x24, 0x6d, 0x6f, 0x6e, 0x67, 0x6f,
0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x77, 0x65, 0x62, 0x61, 0x70, 0x69, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x22, 0x67, 0x0a, 0x13,
0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x54, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
0x02, 0x54, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12,
0x24, 0x0a, 0x0d, 0x4f, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65,
0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x4f, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65,
0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x26, 0x5a, 0x24, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67,
0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x77, 0x65, 0x62, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -6765,7 +6774,7 @@ var file_common_proto_goTypes = []interface{}{
(*GameConfig)(nil), // 52: webapi.GameConfig
(*WelfarePhoneLotteryStatus)(nil), // 53: webapi.WelfarePhoneLotteryStatus
(*WelfareCollectConfig)(nil), // 54: webapi.WelfareCollectConfig
(*ExchangeChannelConfig)(nil), // 55: webapi.ExchangeChannelConfig
(*ChannelSwitchConfig)(nil), // 55: webapi.ChannelSwitchConfig
nil, // 56: webapi.Platform.BindTelRewardEntry
nil, // 57: webapi.PlayerData.RankScoreEntry
nil, // 58: webapi.ItemShop.AwardEntry
@ -7486,7 +7495,7 @@ func file_common_proto_init() {
}
}
file_common_proto_msgTypes[55].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ExchangeChannelConfig); i {
switch v := v.(*ChannelSwitchConfig); i {
case 0:
return &v.state
case 1:

View File

@ -633,8 +633,9 @@ message WelfareCollectConfig{
int32 Switch = 2; // 1. 2.
}
// etcd /game/exchange/channel
message ExchangeChannelConfig{
string Platform = 1;
repeated string OnChannelName = 2; //
// etcd /game/channel/switch
message ChannelSwitchConfig{
int32 Tp = 1; // 1. 2.
string Platform = 2; // id
repeated string OnChannelName = 3; //
}

View File

@ -2240,7 +2240,7 @@ func CSExchangeChannel(s *netlib.Session, packetid int, data interface{}, sid in
}
var onChannelName []string
conf := PlatformMgrSingleton.GetConfig(p.Platform).ExchangeChannelConfig
conf := PlatformMgrSingleton.GetConfig(p.Platform).ChannelSwitch[common.ChannelSwitchExchange]
if conf != nil {
onChannelName = conf.OnChannelName
}

View File

@ -7,6 +7,7 @@ import (
"go.etcd.io/etcd/client/v3"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common"
"mongo.games.com/game/etcd"
hallproto "mongo.games.com/game/protocol/gamehall"
"mongo.games.com/game/protocol/webapi"
@ -35,8 +36,8 @@ func init() {
etcd.Register(etcd.ETCDKEY_SHOP_ITEM, webapi.ItemShopList{}, platformConfigEvent)
// 集卡活动
etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, platformConfigEvent)
// 启动兑换功能的渠道
etcd.Register(etcd.ETCDKEY_EXCHANGECHANNEL, webapi.ExchangeChannelConfig{}, platformConfigEvent)
// 渠道开关
etcd.Register(etcd.ETCDKEY_ChannelSwitch, webapi.ChannelSwitchConfig{}, platformConfigEvent)
}
func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
@ -127,14 +128,18 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e
} else {
TournamentMgr.UpdateData(false, config)
}
case *webapi.ExchangeChannelConfig:
PlatformMgrSingleton.GetConfig(config.Platform).ExchangeChannelConfig = config
case *webapi.ChannelSwitchConfig:
PlatformMgrSingleton.GetConfig(config.Platform).ChannelSwitch[config.GetTp()] = config
if !isInit {
// 通知变更
for _, v := range PlayerMgrSington.playerOfPlatform[config.Platform] {
if v != nil && v.IsOnLine() {
v.SendToClient(int(hallproto.GameHallPacketID_PACKET_SCExchangeChannel), &hallproto.SCExchangeChannel{})
switch config.GetTp() {
case common.ChannelSwitchExchange:
// 通知变更
for _, v := range PlayerMgrSington.playerOfPlatform[config.Platform] {
if v != nil && v.IsOnLine() {
v.SendToClient(int(hallproto.GameHallPacketID_PACKET_SCExchangeChannel), &hallproto.SCExchangeChannel{})
}
}
}
}

View File

@ -490,6 +490,7 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
IParams: p.MarshalIParam(),
SParams: p.MarshalSParam(),
CParams: p.MarshalCParam(),
AppChannel: p.AppChannel,
}
//sa, err2 := p.MarshalSingleAdjustData(this.dbGameFree.Id)
//if err2 == nil && sa != nil {
@ -699,6 +700,7 @@ func (this *Scene) AudienceEnter(p *Player, ischangeroom bool) bool {
IParams: p.MarshalIParam(),
SParams: p.MarshalSParam(),
CParams: p.MarshalCParam(),
AppChannel: p.AppChannel,
}
if !p.IsRob { //保存下进入时的环境