etcd优化
This commit is contained in:
parent
65aa4efebb
commit
9a9c62c1da
|
@ -28,11 +28,11 @@ func platformConfigEtcd(ctx context.Context, completeKey string, isInit bool, ev
|
|||
}
|
||||
switch d := data.(type) {
|
||||
case *webapi.PlayerPool:
|
||||
ConfigMgrInst.GetAllConfig(d.Platform).PlayerPool = d
|
||||
ConfigMgrInst.GetConfig(d.Platform).PlayerPool = d
|
||||
case *webapi.GameConfig:
|
||||
ConfigMgrInst.GetAllConfig(d.Platform).GameConfig = d
|
||||
ConfigMgrInst.GetConfig(d.Platform).GameConfig = d
|
||||
case *webapi.WelfareCollectConfig:
|
||||
ConfigMgrInst.GetAllConfig(d.Platform).WelfareCollectConfig = d
|
||||
ConfigMgrInst.GetConfig(d.Platform).WelfareCollectConfig = d
|
||||
default:
|
||||
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
||||
}
|
||||
|
|
|
@ -2376,7 +2376,7 @@ func (this *Scene) TryBillExGameDrop(p *Player) {
|
|||
|
||||
// DropCollectBox 掉落集卡礼盒
|
||||
func (this *Scene) DropCollectBox(p *Player) {
|
||||
if p == nil || p.IsRob || ConfigMgrInst.GetAllConfig(p.Platform).WelfareCollectConfig.Switch != model.WelfareOpen {
|
||||
if p == nil || p.IsRob || ConfigMgrInst.GetConfig(p.Platform).WelfareCollectConfig.Switch != model.WelfareOpen {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2436,7 +2436,7 @@ func (this *Scene) GetBaseScore() int32 {
|
|||
}
|
||||
|
||||
func (this *Scene) PlayerPoolOdds(p *Player) int32 {
|
||||
config := ConfigMgrInst.GetAllConfig(p.Platform).PlayerPool
|
||||
config := ConfigMgrInst.GetConfig(p.Platform).PlayerPool
|
||||
if config == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -2490,7 +2490,7 @@ func (this *Scene) GetPlayerOdds(p *Player, gameId int, hasRobot bool) int32 {
|
|||
// 场次水池概率
|
||||
f = CoinPoolMgr.GetCoinPoolOdds(this.Platform, this.GetGameFreeId(), this.GroupId)
|
||||
|
||||
cfg := ConfigMgrInst.GetAllConfig(p.Platform).PlayerPool
|
||||
cfg := ConfigMgrInst.GetConfig(p.Platform).PlayerPool
|
||||
if cfg != nil && cfg.PlayerPoolSwitch {
|
||||
if g > 0 {
|
||||
t = f + (1000-f)*g/1000
|
||||
|
@ -2707,7 +2707,7 @@ func (this *Scene) Statistics(param *StaticParam) {
|
|||
|
||||
// 个人输赢统计条件(个人水池)
|
||||
// 黑白名单和新手调控,溢出金币统计到个人水池
|
||||
cfg := ConfigMgrInst.GetAllConfig(p.Platform).PlayerPool
|
||||
cfg := ConfigMgrInst.GetConfig(p.Platform).PlayerPool
|
||||
isPlayerPool := cfg != nil && cfg.PlayerPoolSwitch && isControl && ((wbLevel == 0 && !isNovice) || addGain > 0)
|
||||
if isPlayerPool {
|
||||
keyGameType := common.GetKeyGameType(int(this.GetDBGameFree().GetGameType()))
|
||||
|
|
|
@ -1184,7 +1184,7 @@ func (this *TienLenSceneData) SendHandCardOdds() {
|
|||
}
|
||||
}
|
||||
|
||||
gameConfig := base.ConfigMgrInst.GetAllConfig(this.Platform).GameConfig
|
||||
gameConfig := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig
|
||||
|
||||
// testPokers 用于测试
|
||||
isTestPoker := false
|
||||
|
@ -1228,7 +1228,7 @@ func (this *TienLenSceneData) SendHandCardOdds() {
|
|||
logger.Logger.Tracef("TienLen SendHandCardOdds Good:%v G:%v Bad:%v B:%v", isGood, G, isBad, B)
|
||||
|
||||
if isBad && !isTestPoker && len(robotPlayers) > 0 && !noviceCtrl && !noviceTianHu {
|
||||
gf := base.ConfigMgrInst.GetAllConfig(this.Platform).GameConfig
|
||||
gf := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig
|
||||
items := []int32{gf.GetTianHu(), gf.GetPaiKu(), gf.GetFenCha()}
|
||||
score := this.RandInt(int(gf.GetTianHu() + gf.GetPaiKu() + gf.GetFenCha()))
|
||||
sum := int32(0)
|
||||
|
|
164
model/config.go
164
model/config.go
|
@ -1,6 +1,9 @@
|
|||
package model
|
||||
|
||||
import webapiproto "mongo.games.com/game/protocol/webapi"
|
||||
import (
|
||||
"mongo.games.com/game/protocol/shop"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
)
|
||||
|
||||
/*
|
||||
通用模型定义在这里,如果需要自定义可以内嵌在新结构体中
|
||||
|
@ -22,57 +25,170 @@ const (
|
|||
WelfareClose = 2 // 关闭
|
||||
)
|
||||
|
||||
func NewConfigMgr() *ConfigMgr {
|
||||
return &ConfigMgr{
|
||||
Platform: make(map[string]*AllConfig),
|
||||
Global: new(GlobalConfig),
|
||||
}
|
||||
type ShopInfo struct {
|
||||
Id int32 // 商品ID
|
||||
Page int32 // 页面 1,金币页面 2,钻石页面 3,道具页面
|
||||
Order int32 // 排序 页面内商品的位置排序
|
||||
Location []int32 // 显示位置 第1位,竖版大厅 第2位,Tienlen1级选场 第3位,捕鱼1级选场
|
||||
Picture string // 图片id
|
||||
Name string // 名称
|
||||
Label []int32 // 标签
|
||||
Ad int32 // 是否观看广告 0不看
|
||||
AdTime int32 // 观看几次广告
|
||||
RepeatTimes int32 // 领取次数
|
||||
CoolingTime []int32 // 观看冷却时间
|
||||
Type int32 // 获得类型 1,金币 2,钻石 3,道具类型
|
||||
Amount int64 // 获得数量
|
||||
AddArea []int32 // 加送百分比(比如加送10%,就配置110)
|
||||
ItemId int32 // 获得道具ID
|
||||
AddItemInfo []*shop.ItemInfo // 获得道具
|
||||
ConstType int32 // 购买消耗类型 1,金币 2,钻石 3,美金 4,柬埔寨币
|
||||
CostArea []int32 // 消耗数量区间
|
||||
VipLevel int32 //Vip等级限制
|
||||
Ratio int32 //权重
|
||||
EndTime int32 //新手礼包结束时间间隔
|
||||
//缓存数据
|
||||
AdLookedNum int32 //已经观看的次数
|
||||
AdReceiveNum int32 //已经领取的次数
|
||||
RemainingTime int32
|
||||
LastLookTime int32
|
||||
RoleAdded int32
|
||||
PetAdded int32
|
||||
RoleAddedId int32 //加成人物ID
|
||||
PetAddedId int32 //加成宠物ID
|
||||
FirstSwitch bool // 首冲翻倍
|
||||
AmountFinal int64 // 实际获得数量
|
||||
}
|
||||
|
||||
type AllConfig struct {
|
||||
// 平台配置
|
||||
Platform *webapi.Platform
|
||||
// 客户端游戏入口开关
|
||||
EntrySwitch *webapi.EntrySwitch
|
||||
// 公告
|
||||
CommonNotices *webapi.CommonNoticeList
|
||||
// 七日签到
|
||||
*webapiproto.Welfare7SignDateList
|
||||
*webapi.Welfare7SignDateList
|
||||
// 转盘
|
||||
*webapiproto.WelfareTurnplateDateList
|
||||
*webapi.WelfareTurnplateDateList
|
||||
// 盲盒
|
||||
*webapiproto.WelfareBlindBoxDataList
|
||||
*webapi.WelfareBlindBoxDataList
|
||||
BlindBoxCycle int32
|
||||
// 首充
|
||||
*webapiproto.WelfareFirstPayDataList
|
||||
*webapi.WelfareFirstPayDataList
|
||||
FirstPayCycle int32
|
||||
// 连续充值
|
||||
*webapiproto.WelfareContinuousPayDataList
|
||||
*webapi.WelfareContinuousPayDataList
|
||||
ContinuousPayCycle int32
|
||||
// 积分换手机
|
||||
*webapiproto.WelfarePhoneLotteryStatus
|
||||
*webapi.WelfarePhoneLotteryStatus
|
||||
// 集卡活动
|
||||
*webapiproto.WelfareCollectConfig
|
||||
*webapi.WelfareCollectConfig
|
||||
// 个人水池
|
||||
*webapiproto.PlayerPool
|
||||
*webapi.PlayerPool
|
||||
// 游戏调控全局配置
|
||||
*webapiproto.GameConfig
|
||||
*webapi.GameConfig
|
||||
// 兑换商品
|
||||
*webapi.ExchangeShopList
|
||||
// 商店
|
||||
ShopInfos map[int32]*ShopInfo // 商品id:商品信息
|
||||
}
|
||||
|
||||
type GlobalConfig struct {
|
||||
// 包对应的平台,包标识
|
||||
PackageList map[string]*webapi.AppInfo
|
||||
// 超管平台游戏开关,游戏id
|
||||
GameStatus map[int32]bool
|
||||
}
|
||||
|
||||
type ConfigMgr struct {
|
||||
Platform map[string]*AllConfig
|
||||
Global *GlobalConfig
|
||||
platform map[string]*AllConfig
|
||||
global *GlobalConfig
|
||||
}
|
||||
|
||||
func (cm *ConfigMgr) GetAllConfig(platform string) *AllConfig {
|
||||
c, ok := cm.Platform[platform]
|
||||
func NewConfigMgr() *ConfigMgr {
|
||||
return &ConfigMgr{
|
||||
platform: make(map[string]*AllConfig),
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *ConfigMgr) GetConfig(platform string) *AllConfig {
|
||||
c, ok := cm.platform[platform]
|
||||
if !ok {
|
||||
c = &AllConfig{}
|
||||
cm.Platform[platform] = c
|
||||
c = &AllConfig{
|
||||
// todo 初始化默认值
|
||||
ShopInfos: make(map[int32]*ShopInfo),
|
||||
}
|
||||
cm.platform[platform] = c
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (cm *ConfigMgr) GetGlobalConfig() *GlobalConfig {
|
||||
if cm.Global == nil {
|
||||
cm.Global = new(GlobalConfig)
|
||||
if cm.global == nil {
|
||||
cm.global = &GlobalConfig{
|
||||
// todo 初始化默认值
|
||||
PackageList: make(map[string]*webapi.AppInfo),
|
||||
GameStatus: make(map[int32]bool),
|
||||
}
|
||||
}
|
||||
return cm.Global
|
||||
return cm.global
|
||||
}
|
||||
|
||||
func (cm *ConfigMgr) GetConfigs() map[string]*AllConfig {
|
||||
return cm.platform
|
||||
}
|
||||
|
||||
// UpdateItemShop 更新商品信息
|
||||
func (cm *ConfigMgr) UpdateItemShop(list *webapi.ItemShopList) {
|
||||
if list == nil {
|
||||
return
|
||||
}
|
||||
|
||||
shopInfos := make(map[int32]*ShopInfo)
|
||||
for _, itemShop := range list.List {
|
||||
var itemInfo []*shop.ItemInfo
|
||||
for key, value := range itemShop.Award {
|
||||
itemInfo = append(itemInfo, &shop.ItemInfo{
|
||||
ItemId: int32(key),
|
||||
ItemNum: value,
|
||||
})
|
||||
}
|
||||
|
||||
shopInfos[itemShop.Id] = &ShopInfo{
|
||||
Id: itemShop.Id,
|
||||
ItemId: itemShop.ItemId,
|
||||
Page: itemShop.Page,
|
||||
Order: itemShop.Order,
|
||||
Type: itemShop.Type,
|
||||
Location: itemShop.Location,
|
||||
Picture: itemShop.Picture,
|
||||
Name: itemShop.Name,
|
||||
Ad: itemShop.Ad,
|
||||
AdTime: itemShop.AdTime,
|
||||
RepeatTimes: itemShop.RepeatTimes,
|
||||
CoolingTime: itemShop.CoolingTime,
|
||||
Label: itemShop.Label,
|
||||
AddArea: itemShop.AddArea,
|
||||
Amount: int64(itemShop.Amount),
|
||||
ConstType: itemShop.ConstType,
|
||||
CostArea: itemShop.CostArea,
|
||||
AddItemInfo: itemInfo,
|
||||
VipLevel: itemShop.VipLevel,
|
||||
Ratio: itemShop.Ratio,
|
||||
EndTime: itemShop.EndTime,
|
||||
FirstSwitch: itemShop.FirstSwitch,
|
||||
}
|
||||
}
|
||||
cm.GetConfig(list.Platform).ShopInfos = shopInfos
|
||||
}
|
||||
|
||||
// GetShopInfo 获取商品信息
|
||||
func (cm *ConfigMgr) GetShopInfo(plt string, shopId int32) *ShopInfo {
|
||||
if shops := cm.GetConfig(plt).ShopInfos; shops != nil {
|
||||
if info, ok1 := shops[shopId]; ok1 {
|
||||
return info
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -264,7 +264,6 @@ func init() {
|
|||
} else {
|
||||
logger.Logger.Trace("游戏结束------", scene.gameId, scene.sceneId, scene.replayCode, scene.currRound)
|
||||
}
|
||||
PlatformMgrSingleton.OnChangeSceneState(scene, scene.starting)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -282,7 +281,6 @@ func init() {
|
|||
if scene != nil {
|
||||
scene.state = msg.GetCurrState()
|
||||
scene.fishing = msg.GetFishing()
|
||||
PlatformMgrSingleton.OnChangeSceneState(scene, scene.starting)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -578,7 +578,10 @@ func (this *CSUpdateVipShopHandler) Process(s *netlib.Session, packetid int, dat
|
|||
RefreshCount: p.VipShopRefreshCount, //玩家当前刷新次数
|
||||
}
|
||||
for i, info := range p.VipShopData {
|
||||
si := ShopMgrSington.ShopInfos[p.Platform][info.Id]
|
||||
si := ShopMgrSington.GetConfig(p.Platform).ShopInfos[info.Id]
|
||||
if si == nil {
|
||||
continue
|
||||
}
|
||||
data := &shop.ShopInfo{
|
||||
Id: info.Id,
|
||||
AdLookedNum: si.AdLookedNum,
|
||||
|
|
141
worldsrv/etcd.go
141
worldsrv/etcd.go
|
@ -2,66 +2,131 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"go.etcd.io/etcd/client/v3"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
"mongo.games.com/game/etcd"
|
||||
hallproto "mongo.games.com/game/protocol/gamehall"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 平台配置
|
||||
etcd.Register(etcd.ETCDKEY_PLATFORM_PREFIX, webapi.Platform{}, platformConfigEvent)
|
||||
// 游戏场次配置
|
||||
etcd.Register(etcd.ETCDKEY_GAMECONFIG_PREFIX, webapi.GameFree{}, platformConfigEvent)
|
||||
// 超管平台游戏开关
|
||||
etcd.Register(etcd.ETCDKEY_GAME_CONFIG_GLOBAL, webapi.GameConfigGlobal{}, platformConfigEvent)
|
||||
// 平台包数据
|
||||
etcd.Register(etcd.ETCDKEY_PACKAGE_PREFIX, webapi.AppInfo{}, platformConfigEvent)
|
||||
// 客户端游戏入口开关
|
||||
etcd.Register(etcd.ETCDKEY_PACKAGE_ENTRYSWITCH, webapi.EntrySwitch{}, platformConfigEvent)
|
||||
// 公告
|
||||
etcd.Register(etcd.ETCDKEY_GAME_NOTICE, webapi.CommonNoticeList{}, platformConfigEvent)
|
||||
// 比赛配置
|
||||
etcd.Register(etcd.ETCDKEY_GAME_MATCH, webapi.GameMatchDateList{}, platformConfigEvent)
|
||||
// 个人水池配置
|
||||
etcd.Register(etcd.ETCDKEY_PLAYERPOOL, webapi.PlayerPool{}, PlatformConfigEtcd)
|
||||
etcd.Register(etcd.ETCDKEY_PLAYERPOOL, webapi.PlayerPool{}, platformConfigEvent)
|
||||
// 商品兑换
|
||||
etcd.Register(etcd.ETCDKEY_SHOP_EXCHANGE, webapi.ExchangeShopList{}, ExchangeShopList)
|
||||
etcd.Register(etcd.ETCDKEY_SHOP_EXCHANGE, webapi.ExchangeShopList{}, platformConfigEvent)
|
||||
// 商城商品
|
||||
etcd.Register(etcd.ETCDKEY_SHOP_ITEM, webapi.ItemShopList{}, ItemShopList)
|
||||
etcd.Register(etcd.ETCDKEY_SHOP_ITEM, webapi.ItemShopList{}, platformConfigEvent)
|
||||
// 集卡活动
|
||||
etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, WelfareCollectConfig)
|
||||
etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, platformConfigEvent)
|
||||
}
|
||||
|
||||
//func ExchangeShopList(completeKey string, isInit bool, event *clientv3.Event, data interface{}) {}
|
||||
|
||||
func WelfareCollectConfig(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||
func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||
if event.Type == clientv3.EventTypeDelete {
|
||||
return
|
||||
}
|
||||
config, ok := data.(*webapi.WelfareCollectConfig)
|
||||
if !ok {
|
||||
logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey)
|
||||
return
|
||||
}
|
||||
WelfareMgrSington.UpdateCollectConfig(config)
|
||||
}
|
||||
|
||||
func ItemShopList(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||
if event.Type == clientv3.EventTypeDelete {
|
||||
if data == nil {
|
||||
return
|
||||
}
|
||||
config, ok := data.(*webapi.ItemShopList)
|
||||
if !ok {
|
||||
logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey)
|
||||
return
|
||||
}
|
||||
ShopMgrSington.UpdateItemShop(config)
|
||||
}
|
||||
|
||||
func PlatformConfigEtcd(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||
if event.Type == clientv3.EventTypeDelete {
|
||||
return
|
||||
}
|
||||
PlatformMgrSingleton.UpdateConfig(data)
|
||||
}
|
||||
switch config := data.(type) {
|
||||
case *webapi.WelfareCollectConfig:
|
||||
WelfareMgrSington.UpdateCollectConfig(config)
|
||||
case *webapi.ItemShopList:
|
||||
ShopMgrSington.UpdateItemShop(config)
|
||||
case *webapi.ExchangeShopList:
|
||||
ShopMgrSington.UpExShop(config)
|
||||
case *webapi.PlayerPool:
|
||||
PlatformMgrSingleton.GetConfig(config.Platform).PlayerPool = config
|
||||
case *webapi.EntrySwitch:
|
||||
PlatformMgrSingleton.GetConfig(config.Platform).EntrySwitch = config
|
||||
PlatformMgrSingleton.ChangeEntrySwitch(config.Platform, config)
|
||||
case *webapi.CommonNoticeList:
|
||||
PlatformMgrSingleton.GetConfig(config.Platform).CommonNotices = config
|
||||
if !isInit {
|
||||
// 通知公共变更
|
||||
for _, v := range PlayerMgrSington.playerOfPlatform[config.Platform] {
|
||||
if v != nil && v.IsOnLine() {
|
||||
v.SendToClient(int(hallproto.GameHallPacketID_PACKET_SC_NoticeChange), &hallproto.SCNoticeChange{})
|
||||
}
|
||||
}
|
||||
}
|
||||
case *webapi.GameConfigGlobal:
|
||||
if isInit {
|
||||
for _, v := range config.GetGameStatus() {
|
||||
gameId := v.GetGameId()
|
||||
status := v.GetStatus()
|
||||
PlatformMgrSingleton.GetGlobalConfig().GameStatus[gameId] = status
|
||||
}
|
||||
} else {
|
||||
cfgs := make([]*hallproto.GameConfig1, 0)
|
||||
for _, v := range config.GetGameStatus() {
|
||||
gameId := v.GetGameId() // gamefreeid
|
||||
status := v.GetStatus()
|
||||
if PlatformMgrSingleton.GetGlobalConfig().GameStatus[gameId] != status {
|
||||
cfgs = append(cfgs, &hallproto.GameConfig1{
|
||||
LogicId: gameId,
|
||||
Status: status,
|
||||
})
|
||||
}
|
||||
PlatformMgrSingleton.GetGlobalConfig().GameStatus[gameId] = status
|
||||
}
|
||||
PlatformMgrSingleton.ChangeGameStatus(cfgs)
|
||||
}
|
||||
case *webapi.Platform:
|
||||
if isInit {
|
||||
PlatformMgrSingleton.CreateDefaultPlatform()
|
||||
}
|
||||
PlatformMgrSingleton.UpsertPlatform(config.PlatformName, config.Isolated, config.Disabled, config.Id,
|
||||
config.CustomService, config.BindOption, config.ServiceFlag, config.UpgradeAccountGiveCoin,
|
||||
config.NewAccountGiveCoin, config.PerBankNoLimitAccount, config.ExchangeMin, config.ExchangeLimit,
|
||||
config.ExchangeTax, config.ExchangeFlow, config.ExchangeFlag, config.SpreadConfig, config.VipRange, "",
|
||||
nil, config.VerifyCodeType, nil /*config.ThirdGameMerchant,*/, config.CustomType,
|
||||
false, config.NeedSameName, config.ExchangeForceTax, config.ExchangeGiveFlow, config.ExchangeVer,
|
||||
config.ExchangeBankMax, config.ExchangeAlipayMax, 0, config.PerBankNoLimitName, config.IsCanUserBindPromoter,
|
||||
config.UserBindPromoterPrize, false, config.ExchangeMultiple, false, config.MerchantKey,
|
||||
config.BindTelReward)
|
||||
case *webapi.GameFree:
|
||||
var err error
|
||||
s := strings.TrimPrefix(completeKey, etcd.ETCDKEY_GAMECONFIG_PREFIX)
|
||||
arr := strings.Split(s, "/")
|
||||
if len(arr) > 1 {
|
||||
pltId := arr[0]
|
||||
if err == nil {
|
||||
PlatformMgrSingleton.UpsertGameFree(pltId, config)
|
||||
}
|
||||
}
|
||||
case *webapi.AppInfo:
|
||||
if config.PlatformId == 0 {
|
||||
config.PlatformId = int32(DefaultPlatformInt)
|
||||
}
|
||||
PlatformMgrSingleton.GetGlobalConfig().PackageList[config.PackageName] = config
|
||||
PlatformMgrSingleton.GetGlobalConfig().PackageList[config.BundleId] = config
|
||||
case *webapi.GameMatchDateList:
|
||||
if isInit {
|
||||
TournamentMgr.UpdateData(true, config)
|
||||
} else {
|
||||
TournamentMgr.UpdateData(false, config)
|
||||
}
|
||||
|
||||
func ExchangeShopList(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||
if event.Type == clientv3.EventTypeDelete {
|
||||
return
|
||||
default:
|
||||
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
||||
}
|
||||
config, ok := data.(*webapi.ExchangeShopList)
|
||||
if !ok {
|
||||
logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey)
|
||||
return
|
||||
}
|
||||
ShopMgrSington.UpExShop(config)
|
||||
}
|
||||
|
|
1662
worldsrv/etcdmgr.go
1662
worldsrv/etcdmgr.go
File diff suppressed because it is too large
Load Diff
|
@ -6,6 +6,7 @@ import (
|
|||
"mongo.games.com/goserver/core/module"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
hall_proto "mongo.games.com/game/protocol/gamehall"
|
||||
"mongo.games.com/game/protocol/pets"
|
||||
"mongo.games.com/game/srvdata"
|
||||
|
@ -233,7 +234,7 @@ func (this *PetMgr) GetPetInfo(p *Player, modId int32) *pets.PetInfo {
|
|||
}
|
||||
|
||||
// 商品人物总加成 人物功能变动需要修改
|
||||
func (this *PetMgr) GetShopAward(shopInfo *ShopInfo, p *Player) (award, roleId int32) {
|
||||
func (this *PetMgr) GetShopAward(shopInfo *model.ShopInfo, p *Player) (award, roleId int32) {
|
||||
if shopInfo.Ad > 0 && shopInfo.Type == ShopTypeCoin {
|
||||
id, add := srvdata.RolePetMgrSington.GetRoleAdd(p.PlayerData, common.RoleAddADV)
|
||||
award += add
|
||||
|
|
|
@ -89,28 +89,28 @@ type Platform struct {
|
|||
IsCanUserBindPromoter bool //是否允许用户手动绑定推广员
|
||||
UserBindPromoterPrize int32 //手动绑定奖励
|
||||
SpreadWinLose bool //是否打开客损开关
|
||||
PltGameCfg *PlatformGameConfig //平台游戏配置
|
||||
GameConfig *GameList //平台游戏配置
|
||||
MerchantKey string //商户秘钥
|
||||
BindTelReward map[int32]int64 // 绑定手机号奖励
|
||||
}
|
||||
|
||||
type PlatformGameConfig struct {
|
||||
games map[int32]*webapiproto.GameFree //以gamefreeid为key
|
||||
cache map[int32][]*webapiproto.GameFree //以gameid为key
|
||||
type GameList struct {
|
||||
gameFreeId map[int32]*webapiproto.GameFree // 以gamefreeid为key
|
||||
gameId map[int32][]*webapiproto.GameFree // 以gameid为key
|
||||
}
|
||||
|
||||
func (cfg *PlatformGameConfig) RecreateCache() {
|
||||
if cfg.cache == nil {
|
||||
cfg.cache = make(map[int32][]*webapiproto.GameFree)
|
||||
func (cfg *GameList) Init() {
|
||||
if cfg.gameId == nil {
|
||||
cfg.gameId = make(map[int32][]*webapiproto.GameFree)
|
||||
}
|
||||
for _, val := range cfg.games {
|
||||
cfg.cache[val.DbGameFree.GetGameId()] = append(cfg.cache[val.DbGameFree.GetGameId()], val)
|
||||
for _, val := range cfg.gameFreeId {
|
||||
cfg.gameId[val.DbGameFree.GetGameId()] = append(cfg.gameId[val.DbGameFree.GetGameId()], val)
|
||||
}
|
||||
}
|
||||
|
||||
func (cfg *PlatformGameConfig) GetGameCfg(gamefreeId int32) *webapiproto.GameFree {
|
||||
if cfg.games != nil {
|
||||
if c, exist := cfg.games[gamefreeId]; exist {
|
||||
func (cfg *GameList) GetGameConfig(gameFreeId int32) *webapiproto.GameFree {
|
||||
if cfg.gameFreeId != nil {
|
||||
if c, exist := cfg.gameFreeId[gameFreeId]; exist {
|
||||
if c.GroupId == 0 {
|
||||
return c
|
||||
} else {
|
||||
|
@ -123,7 +123,7 @@ func (cfg *PlatformGameConfig) GetGameCfg(gamefreeId int32) *webapiproto.GameFre
|
|||
return temp
|
||||
}
|
||||
} else {
|
||||
//logger.Logger.Errorf("PlatformGameConfig GetGameCfg Can't Find GameCfg[%v]", gamefreeId)
|
||||
//logger.Logger.Errorf("GameList GetGameConfig Can't Find GameCfg[%v]", gameFreeId)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -185,10 +185,12 @@ func NewPlatform(id int32, isolated bool) *Platform {
|
|||
Halls: make(map[int32]*PlatformGameHall),
|
||||
GamePlayerNum: make(map[int32]*PlatformGamePlayerNum),
|
||||
ClubConfig: &ClubConfig{},
|
||||
PltGameCfg: &PlatformGameConfig{
|
||||
games: make(map[int32]*webapiproto.GameFree),
|
||||
cache: make(map[int32][]*webapiproto.GameFree),
|
||||
GameConfig: &GameList{
|
||||
gameFreeId: make(map[int32]*webapiproto.GameFree),
|
||||
gameId: make(map[int32][]*webapiproto.GameFree),
|
||||
},
|
||||
ThirdGameMerchant: make(map[int32]int32),
|
||||
BindTelReward: make(map[int32]int64),
|
||||
}
|
||||
|
||||
return p
|
||||
|
@ -230,14 +232,6 @@ func (p *Platform) ChangeDisabled(disable bool) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (p *Platform) PlayerLogin(player *Player) {
|
||||
|
||||
}
|
||||
|
||||
func (p *Platform) PlayerLogout(player *Player) {
|
||||
|
||||
}
|
||||
|
||||
func (p *Platform) IsMarkFlag(flag int32) bool {
|
||||
if (p.BindOption & flag) != 0 {
|
||||
return true
|
||||
|
|
|
@ -24,14 +24,6 @@ const (
|
|||
DefaultPlatformInt = 0
|
||||
)
|
||||
|
||||
// PlatformConfig 所有跟平台相关的配置,不要再定义map数据结构了
|
||||
type PlatformConfig struct {
|
||||
Platform *Platform // 平台配置
|
||||
EntrySwitch *webapiproto.EntrySwitch // 客户端游戏入口开关
|
||||
CommonNotices *webapiproto.CommonNoticeList // 公告
|
||||
PlayerPool *webapiproto.PlayerPool // 个人水池配置
|
||||
}
|
||||
|
||||
type PlatformObserver interface {
|
||||
OnPlatformCreate(p *Platform)
|
||||
OnPlatformDestroy(p *Platform)
|
||||
|
@ -41,81 +33,75 @@ type PlatformObserver interface {
|
|||
}
|
||||
|
||||
var PlatformMgrSingleton = &PlatformMgr{
|
||||
configs: make(map[string]*PlatformConfig),
|
||||
PackageList: make(map[string]*webapiproto.AppInfo),
|
||||
GameStatus: make(map[int32]bool), //全局游戏开关
|
||||
platforms: make(map[string]*Platform),
|
||||
ConfigMgr: model.NewConfigMgr(),
|
||||
}
|
||||
|
||||
type PlatformMgr struct {
|
||||
BaseClockSinker
|
||||
|
||||
//todo 所有跟平台相关的配置,不要再定义map数据结构了
|
||||
configs map[string]*PlatformConfig
|
||||
|
||||
PackageList map[string]*webapiproto.AppInfo // 包对应的平台,包标识
|
||||
GameStatus map[int32]bool // 超管平台游戏开关,游戏id
|
||||
|
||||
Observers []PlatformObserver
|
||||
*model.ConfigMgr
|
||||
platforms map[string]*Platform
|
||||
observers []PlatformObserver
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) RegisterObserver(observer PlatformObserver) {
|
||||
for _, ob := range pm.Observers {
|
||||
for _, ob := range pm.observers {
|
||||
if ob == observer {
|
||||
return
|
||||
}
|
||||
}
|
||||
pm.Observers = append(pm.Observers, observer)
|
||||
pm.observers = append(pm.observers, observer)
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) UnregisterObserver(observer PlatformObserver) {
|
||||
for i, ob := range pm.Observers {
|
||||
for i, ob := range pm.observers {
|
||||
if ob == observer {
|
||||
pm.Observers = append(pm.Observers[:i], pm.Observers[i+1:]...)
|
||||
pm.observers = append(pm.observers[:i], pm.observers[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetPlatforms 获取所有平台
|
||||
func (pm *PlatformMgr) GetPlatforms() []*Platform {
|
||||
var ret []*Platform
|
||||
for _, v := range pm.configs {
|
||||
if v != nil && v.Platform != nil {
|
||||
ret = append(ret, v.Platform)
|
||||
for _, v := range pm.platforms {
|
||||
if v != nil {
|
||||
ret = append(ret, v)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) CreatePlatform(id int32, isolated bool) *Platform {
|
||||
pltId := strconv.Itoa(int(id))
|
||||
p := NewPlatform(id, isolated)
|
||||
pm.Get(pltId).Platform = p
|
||||
if p != nil {
|
||||
pm.OnPlatformCreate(p)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// CreateDefaultPlatform 创建默认平台
|
||||
func (pm *PlatformMgr) CreateDefaultPlatform() {
|
||||
//默认平台数据
|
||||
defaultPlatform := pm.CreatePlatform(DefaultPlatformInt, false)
|
||||
defaultPlatform.Disable = false
|
||||
//默认平台配置
|
||||
pgc := defaultPlatform.PltGameCfg
|
||||
if pgc != nil {
|
||||
list := defaultPlatform.GameConfig
|
||||
if list != nil {
|
||||
for _, value := range srvdata.PBDB_GameFreeMgr.Datas.Arr {
|
||||
if value.GetGameId() > 0 {
|
||||
pgc.games[value.GetId()] = &webapiproto.GameFree{
|
||||
list.gameFreeId[value.GetId()] = &webapiproto.GameFree{
|
||||
Status: true,
|
||||
DbGameFree: value,
|
||||
}
|
||||
}
|
||||
}
|
||||
pgc.RecreateCache()
|
||||
list.Init()
|
||||
}
|
||||
}
|
||||
|
||||
// CreatePlatform 创建平台
|
||||
func (pm *PlatformMgr) CreatePlatform(id int32, isolated bool) *Platform {
|
||||
pltId := strconv.Itoa(int(id))
|
||||
p := NewPlatform(id, isolated)
|
||||
pm.platforms[pltId] = p
|
||||
pm.OnPlatformCreate(p)
|
||||
return p
|
||||
}
|
||||
|
||||
// UpsertPlatform 更新或新增平台
|
||||
func (pm *PlatformMgr) UpsertPlatform(name string, isolated, disable bool, id int32, url string,
|
||||
bindOption int32, serviceFlag bool, upgradeAccountGiveCoin, newAccountGiveCoin, perBankNoLimitAccount, exchangeMin,
|
||||
|
@ -126,7 +112,7 @@ func (pm *PlatformMgr) UpsertPlatform(name string, isolated, disable bool, id in
|
|||
userBindPromoterPrize int32, spreadWinLose bool, exchangeMultiple int32, registerVerifyCodeSwitch bool, merchantKey string,
|
||||
bindTelReward map[int32]int64) *Platform {
|
||||
pltId := strconv.Itoa(int(id))
|
||||
p := pm.Get(pltId).Platform
|
||||
p := pm.platforms[pltId]
|
||||
if p == nil {
|
||||
p = pm.CreatePlatform(id, isolated)
|
||||
}
|
||||
|
@ -188,50 +174,17 @@ func (pm *PlatformMgr) UpsertPlatform(name string, isolated, disable bool, id in
|
|||
return p
|
||||
}
|
||||
|
||||
// Get 获取平台相关配置,不会返回nil
|
||||
func (pm *PlatformMgr) Get(plt string) *PlatformConfig {
|
||||
cfg, ok := pm.configs[plt]
|
||||
if !ok {
|
||||
cfg = new(PlatformConfig)
|
||||
pm.configs[plt] = cfg
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) UpdateConfig(config any) {
|
||||
if config == nil {
|
||||
return
|
||||
}
|
||||
switch v := config.(type) {
|
||||
case *webapiproto.PlayerPool:
|
||||
this.Get(v.GetPlatform()).PlayerPool = v
|
||||
default:
|
||||
logger.Logger.Errorf("unknown config type:%v", config)
|
||||
}
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) UpdateEntrySwitch(config *webapiproto.EntrySwitch) {
|
||||
if config == nil {
|
||||
return
|
||||
}
|
||||
pm.Get(config.Platform).EntrySwitch = config
|
||||
}
|
||||
|
||||
// GetEntrySwitch 获取入口开关
|
||||
func (pm *PlatformMgr) GetEntrySwitch(plt string) *webapiproto.EntrySwitch {
|
||||
return pm.Get(plt).EntrySwitch
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) UpdateCommonNotices(config *webapiproto.CommonNoticeList) {
|
||||
if config == nil {
|
||||
return
|
||||
}
|
||||
pm.Get(config.Platform).CommonNotices = config
|
||||
return pm.GetConfig(plt).EntrySwitch
|
||||
}
|
||||
|
||||
// GetCommonNotices 获取公告
|
||||
func (pm *PlatformMgr) GetCommonNotices(plt string) *webapiproto.CommonNoticeList {
|
||||
return pm.Get(plt).CommonNotices
|
||||
return pm.GetConfig(plt).CommonNotices
|
||||
}
|
||||
|
||||
// SyncGameFree 通知游戏配置更新
|
||||
func (pm *PlatformMgr) SyncGameFree(platform string, data *webapiproto.GameFree) {
|
||||
packSgf := &loginproto.SCSyncGameFree{}
|
||||
gc := &loginproto.GameConfig{
|
||||
|
@ -260,7 +213,7 @@ func (pm *PlatformMgr) SyncGameFree(platform string, data *webapiproto.GameFree)
|
|||
func (pm *PlatformMgr) UpsertGameFree(platform string, data *webapiproto.GameFree) {
|
||||
p := pm.GetPlatform(platform)
|
||||
if p != nil {
|
||||
pgc := p.PltGameCfg
|
||||
pgc := p.GameConfig
|
||||
if pgc != nil {
|
||||
dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(data.DbGameFree.Id)
|
||||
if dbGameFree == nil {
|
||||
|
@ -272,11 +225,11 @@ func (pm *PlatformMgr) UpsertGameFree(platform string, data *webapiproto.GameFre
|
|||
CopyDBGameFreeField(dbGameFree, data.DbGameFree)
|
||||
}
|
||||
|
||||
old, ok := pgc.games[data.DbGameFree.Id]
|
||||
pgc.games[data.DbGameFree.Id] = data
|
||||
old, ok := pgc.gameFreeId[data.DbGameFree.Id]
|
||||
pgc.gameFreeId[data.DbGameFree.Id] = data
|
||||
found := false
|
||||
if ok && old != nil {
|
||||
if c, ok := pgc.cache[data.DbGameFree.Id]; ok {
|
||||
if c, ok := pgc.gameId[data.DbGameFree.Id]; ok {
|
||||
for i := 0; i < len(c); i++ {
|
||||
if c[i].DbGameFree.Id == data.DbGameFree.Id {
|
||||
c[i] = data
|
||||
|
@ -287,8 +240,9 @@ func (pm *PlatformMgr) UpsertGameFree(platform string, data *webapiproto.GameFre
|
|||
}
|
||||
}
|
||||
if !found {
|
||||
pgc.cache[data.DbGameFree.Id] = append(pgc.cache[data.DbGameFree.Id], data)
|
||||
pgc.gameId[data.DbGameFree.Id] = append(pgc.gameId[data.DbGameFree.Id], data)
|
||||
}
|
||||
// 新增的场次不会通知
|
||||
if ok && old != nil && !CompareGameFreeConfigChged(old, data) {
|
||||
pm.OnPlatformGameFreeUpdate(p, old, data)
|
||||
pm.SyncGameFree(p.IdStr, data)
|
||||
|
@ -298,29 +252,30 @@ func (pm *PlatformMgr) UpsertGameFree(platform string, data *webapiproto.GameFre
|
|||
}
|
||||
|
||||
func (pm *PlatformMgr) OnPlatformCreate(p *Platform) {
|
||||
for _, observer := range pm.Observers {
|
||||
for _, observer := range pm.observers {
|
||||
observer.OnPlatformCreate(p)
|
||||
}
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) OnPlatformGameFreeUpdate(p *Platform, oldCfg, newCfg *webapiproto.GameFree) {
|
||||
for _, observer := range pm.Observers {
|
||||
for _, observer := range pm.observers {
|
||||
observer.OnPlatformGameFreeUpdate(p, oldCfg, newCfg)
|
||||
}
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) OnPlatformDestroyByGameFreeId(p *Platform, gameFreeId int32) {
|
||||
for _, observer := range pm.Observers {
|
||||
for _, observer := range pm.observers {
|
||||
observer.OnPlatformDestroyByGameFreeId(p, gameFreeId)
|
||||
}
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) OnPlatformChangeDisabled(p *Platform, disable bool) {
|
||||
for _, observer := range pm.Observers {
|
||||
for _, observer := range pm.observers {
|
||||
observer.OnPlatformChangeDisabled(p, disable)
|
||||
}
|
||||
}
|
||||
|
||||
// ChangeDisabled 平台开关状态切换
|
||||
func (pm *PlatformMgr) ChangeDisabled(name string, disable bool) {
|
||||
if p := pm.GetPlatform(name); p != nil {
|
||||
if p.ChangeDisabled(disable) {
|
||||
|
@ -330,22 +285,10 @@ func (pm *PlatformMgr) ChangeDisabled(name string, disable bool) {
|
|||
}
|
||||
|
||||
func (pm *PlatformMgr) GetPlatform(platform string) *Platform {
|
||||
return pm.Get(platform).Platform
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) OnChangeSceneState(scene *Scene, startclose bool) {
|
||||
|
||||
}
|
||||
func (pm *PlatformMgr) PlayerLogin(p *Player) {
|
||||
if p.IsRob {
|
||||
return
|
||||
}
|
||||
platform := pm.GetPlatform(p.Platform)
|
||||
if platform != nil {
|
||||
platform.PlayerLogin(p)
|
||||
}
|
||||
return pm.platforms[platform]
|
||||
}
|
||||
|
||||
// Broadcast 给玩家发消息
|
||||
func (pm *PlatformMgr) Broadcast(packetid int, packet interface{}, players map[int32]*Player, exclude int32) {
|
||||
mgs := make(map[*netlib.Session][]*srvlibproto.MCSessionUnion)
|
||||
for _, p := range players {
|
||||
|
@ -367,18 +310,9 @@ func (pm *PlatformMgr) Broadcast(packetid int, packet interface{}, players map[i
|
|||
}
|
||||
}
|
||||
|
||||
func (pm *PlatformMgr) PlayerLogout(p *Player) {
|
||||
platform := pm.GetPlatform(p.Platform)
|
||||
if platform != nil && platform.Isolated {
|
||||
platform.PlayerLogout(p)
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) GetPackageTag(tag string) *webapiproto.AppInfo {
|
||||
logger.Logger.Tracef("Get %v platform.", tag)
|
||||
if pt, ok := this.PackageList[tag]; ok {
|
||||
if pt, ok := this.GetGlobalConfig().PackageList[tag]; ok {
|
||||
return pt
|
||||
}
|
||||
return nil
|
||||
|
@ -386,7 +320,7 @@ func (this *PlatformMgr) GetPackageTag(tag string) *webapiproto.AppInfo {
|
|||
|
||||
func (this *PlatformMgr) GetPlatformByPackageTag(tag string) (int32, int32, int32, int32, int32) {
|
||||
logger.Logger.Tracef("Get %v platform.", tag)
|
||||
if pt, ok := this.PackageList[tag]; ok {
|
||||
if pt, ok := this.GetGlobalConfig().PackageList[tag]; ok {
|
||||
return pt.PlatformId, 0, 0, 0, 0
|
||||
} else {
|
||||
return int32(DefaultPlatformInt), 0, 0, 0, 0
|
||||
|
@ -395,25 +329,13 @@ func (this *PlatformMgr) GetPlatformByPackageTag(tag string) (int32, int32, int3
|
|||
|
||||
func (this *PlatformMgr) GetCurrencyByPackageTag(tag string) (string, int32) {
|
||||
logger.Logger.Tracef("Get %v CurrencyRatio.", tag)
|
||||
if pt, ok := this.PackageList[tag]; ok && pt.CurrencyType != "" && pt.CurrencyRatio != 0 {
|
||||
if pt, ok := this.GetGlobalConfig().PackageList[tag]; ok && pt.CurrencyType != "" && pt.CurrencyRatio != 0 {
|
||||
return pt.CurrencyType, pt.CurrencyRatio
|
||||
}
|
||||
return "USD", 1
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) GetPlatformUpgradeAccountGiveCoinByPackageTag(tag string) int32 {
|
||||
platform, _, _, _, _ := this.GetPlatformByPackageTag(tag)
|
||||
return this.GetPlatformUpgradeAccountGiveCoinByPlatform(strconv.Itoa(int(platform)))
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) GetPlatformUpgradeAccountGiveCoinByPlatform(platform string) int32 {
|
||||
platformData := this.GetPlatform(platform)
|
||||
if platformData == nil {
|
||||
return 0
|
||||
}
|
||||
return platformData.UpgradeAccountGiveCoin
|
||||
}
|
||||
|
||||
// GetGameFrees 获取平台游戏配置
|
||||
func (this *PlatformMgr) GetGameFrees(platform string) map[int32]*webapiproto.GameFree {
|
||||
p := this.GetPlatform(platform)
|
||||
if p == nil {
|
||||
|
@ -421,8 +343,8 @@ func (this *PlatformMgr) GetGameFrees(platform string) map[int32]*webapiproto.Ga
|
|||
}
|
||||
|
||||
data := make(map[int32]*webapiproto.GameFree)
|
||||
for id, val := range p.PltGameCfg.games {
|
||||
if !val.Status || !this.GameStatus[id] {
|
||||
for id, val := range p.GameConfig.gameFreeId {
|
||||
if !val.Status || !this.GetGlobalConfig().GameStatus[id] {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -443,18 +365,19 @@ func (this *PlatformMgr) GetGameFrees(platform string) map[int32]*webapiproto.Ga
|
|||
return data
|
||||
}
|
||||
|
||||
// GetGameFree 获取平台游戏配置
|
||||
func (this *PlatformMgr) GetGameFree(platform string, gameFreeId int32) *webapiproto.GameFree {
|
||||
p := this.GetPlatform(platform)
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
gf := p.PltGameCfg.GetGameCfg(gameFreeId)
|
||||
gf := p.GameConfig.GetGameConfig(gameFreeId)
|
||||
if gf == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !this.GameStatus[gameFreeId] || !gf.GetStatus() {
|
||||
if !this.GetGlobalConfig().GameStatus[gameFreeId] || !gf.GetStatus() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -504,7 +427,7 @@ func (this *PlatformMgr) ChangeGameStatus(cfgs []*hallproto.GameConfig1) {
|
|||
for _, p := range this.GetPlatforms() {
|
||||
for _, cfg := range cfgs {
|
||||
gameFreeId := cfg.LogicId
|
||||
data, ok := p.PltGameCfg.games[gameFreeId]
|
||||
data, ok := p.GameConfig.gameFreeId[gameFreeId]
|
||||
if data != nil && ok && data.Status { //自身有这个游戏,且处于开启状态
|
||||
if !cfg.Status { //全局关,销毁游戏
|
||||
pack.GameCfg = append(pack.GameCfg, cfg)
|
||||
|
@ -562,187 +485,6 @@ func (this *PlatformMgr) Init() {
|
|||
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) LoadPlatform() {
|
||||
//构建默认的平台数据
|
||||
this.CreateDefaultPlatform()
|
||||
//获取平台数据 platform_list
|
||||
|
||||
//不使用etcd的情况下走api获取
|
||||
if !model.GameParamData.UseEtcd {
|
||||
//buf, err := webapi.API_GetPlatformData(common.GetAppId())
|
||||
//if err == nil {
|
||||
// ar := webapi_proto.ASPlatformInfo{}
|
||||
// err = proto.Unmarshal(buf, &ar)
|
||||
// if err == nil && ar.Tag == webapi_proto.TagCode_SUCCESS {
|
||||
// for _, value := range ar.Platforms {
|
||||
// platform := this.CreatePlatform(value.Id, value.Isolated)
|
||||
// platform.Name = value.PlatformName
|
||||
// //platform.ConfigId = value.ConfigId
|
||||
// platform.Disable = value.Disabled
|
||||
// platform.ServiceUrl = value.CustomService
|
||||
// platform.CustomType = value.CustomType
|
||||
// platform.BindOption = value.BindOption
|
||||
// //platform.ServiceFlag = value.ServiceFlag
|
||||
// platform.UpgradeAccountGiveCoin = value.UpgradeAccountGiveCoin
|
||||
// platform.NewAccountGiveCoin = value.NewAccountGiveCoin //新账号奖励金币
|
||||
// platform.PerBankNoLimitAccount = value.PerBankNoLimitAccount //同一银行卡号绑定用户数量限制
|
||||
// platform.ExchangeMin = value.ExchangeMin
|
||||
// platform.ExchangeLimit = value.ExchangeLimit
|
||||
// platform.ExchangeTax = value.ExchangeTax
|
||||
// platform.ExchangeFlow = value.ExchangeFlow
|
||||
// platform.ExchangeVer = value.ExchangeVer
|
||||
// platform.ExchangeFlag = value.ExchangeFlag
|
||||
// platform.ExchangeForceTax = value.ExchangeForceTax
|
||||
// platform.ExchangeGiveFlow = value.ExchangeGiveFlow
|
||||
// platform.VipRange = value.VipRange
|
||||
// //platform.OtherParams = value.OtherParams
|
||||
// platform.SpreadConfig = value.SpreadConfig
|
||||
// //platform.RankSwitch = value.Leaderboard
|
||||
// //platform.ClubConfig = value.ClubConfig
|
||||
// platform.VerifyCodeType = value.VerifyCodeType
|
||||
// //platform.RegisterVerifyCodeSwitch = value.RegisterVerifyCodeSwitch
|
||||
// for _, v := range value.ThirdGameMerchant {
|
||||
// platform.ThirdGameMerchant[v.Id] = v.Merchant
|
||||
// }
|
||||
// //platform.NeedDeviceInfo = value.NeedDeviceInfo
|
||||
// platform.NeedSameName = value.NeedSameName
|
||||
// platform.PerBankNoLimitName = value.PerBankNoLimitName
|
||||
// platform.ExchangeAlipayMax = value.ExchangeAlipayMax
|
||||
// platform.ExchangeBankMax = value.ExchangeBankMax
|
||||
// //platform.DgHboConfig = value.DgHboConfig
|
||||
// platform.IsCanUserBindPromoter = value.IsCanUserBindPromoter
|
||||
// platform.UserBindPromoterPrize = value.UserBindPromoterPrize
|
||||
// //platform.SpreadWinLose = value.SpreadWinLose
|
||||
// platform.ExchangeMultiple = value.ExchangeMultiple
|
||||
// if platform.ExchangeFlag&ExchangeFlag_Flow == 0 { //修正下
|
||||
// platform.ExchangeFlow = 0
|
||||
// }
|
||||
// platform.MerchantKey = value.MerchantKey
|
||||
// }
|
||||
// logger.Logger.Trace("Create platform")
|
||||
// } else {
|
||||
// logger.Logger.Error("Unmarshal platform data error:", err)
|
||||
// }
|
||||
//} else {
|
||||
// logger.Logger.Error("Get platfrom data error:", err)
|
||||
//}
|
||||
} else {
|
||||
EtcdMgrSington.InitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) LoadPlatformGameFree() {
|
||||
//不使用etcd的情况下走api获取
|
||||
|
||||
//获取平台详细信息 game_config_list
|
||||
if !model.GameParamData.UseEtcd {
|
||||
//logger.Logger.Trace("API_GetPlatformConfigData")
|
||||
//buf, err := webapi.API_GetPlatformConfigData(common.GetAppId())
|
||||
//if err == nil {
|
||||
// pcdr := &webapi_proto.ASGameConfig{}
|
||||
// err = proto.Unmarshal(buf, pcdr)
|
||||
// if err == nil && pcdr.Tag == webapi_proto.TagCode_SUCCESS {
|
||||
// platGameCfgs := pcdr.GetConfigs()
|
||||
//
|
||||
// //遍历所有平台配置
|
||||
// for _, pgc := range platGameCfgs {
|
||||
// platormId := pgc.GetPlatformId()
|
||||
// platform := this.GetPlatform(strconv.Itoa(int(platormId)))
|
||||
// if platform == nil {
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
// for _, config := range pgc.GetDbGameFrees() {
|
||||
// dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(config.DbGameFree.Id)
|
||||
// if dbGameFree == nil {
|
||||
// logger.Logger.Error("Platform config data error logic id:", config)
|
||||
// continue
|
||||
// }
|
||||
// platform.PltGameCfg.games[config.DbGameFree.Id] = config
|
||||
// if config.GetDbGameFree() == nil { //数据容错
|
||||
// config.DbGameFree = dbGameFree
|
||||
// } else {
|
||||
// CopyDBGameFreeField(dbGameFree, config.DbGameFree)
|
||||
// }
|
||||
// logger.Logger.Info("PlatformGameConfig data:", config.DbGameFree.Id)
|
||||
// }
|
||||
// platform.PltGameCfg.RecreateCache()
|
||||
// }
|
||||
// } else {
|
||||
// logger.Logger.Error("Unmarshal platform config data error:", err, string(buf))
|
||||
// }
|
||||
//} else {
|
||||
// logger.Logger.Error("Get platfrom config data error:", err)
|
||||
//}
|
||||
} else {
|
||||
EtcdMgrSington.InitPlatformGameConfig()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) LoadPlatformPackage() {
|
||||
if !model.GameParamData.UseEtcd {
|
||||
|
||||
} else {
|
||||
EtcdMgrSington.InitPlatformPackage()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) LoadCommonNotice() {
|
||||
if !model.GameParamData.UseEtcd {
|
||||
|
||||
} else {
|
||||
EtcdMgrSington.InitCommonNotice()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) LoadGameMatch() {
|
||||
if !model.GameParamData.UseEtcd {
|
||||
|
||||
} else {
|
||||
EtcdMgrSington.InitGameMatchDate()
|
||||
}
|
||||
}
|
||||
|
||||
// LoadGlobalGameStatus 加载超管平台游戏开关
|
||||
func (this *PlatformMgr) LoadGlobalGameStatus() {
|
||||
//不使用etcd的情况下走api获取
|
||||
if !model.GameParamData.UseEtcd {
|
||||
////获取全局游戏开关
|
||||
//logger.Logger.Trace("API_GetGlobalGameStatus")
|
||||
//buf, err := webapi.API_GetGlobalGameStatus(common.GetAppId())
|
||||
//if err == nil {
|
||||
// as := webapi_proto.ASGameConfigGlobal{}
|
||||
// err = proto.Unmarshal(buf, &as)
|
||||
// if err == nil && as.Tag == webapi_proto.TagCode_SUCCESS {
|
||||
// if as.GetGameStatus() != nil {
|
||||
// status := as.GetGameStatus().GetGameStatus()
|
||||
// for _, v := range status {
|
||||
// gameId := v.GetGameId()
|
||||
// status := v.GetStatus()
|
||||
// PlatformMgrSingleton.GameStatus[gameId] = status
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// logger.Logger.Error("Unmarshal GlobalGameStatus data error:", err)
|
||||
// }
|
||||
//} else {
|
||||
// logger.Logger.Error("Get GlobalGameStatus data error:", err)
|
||||
//}
|
||||
} else {
|
||||
EtcdMgrSington.InitGameGlobalStatus()
|
||||
}
|
||||
}
|
||||
|
||||
// LoadEntrySwitch 拉取界面入口开关
|
||||
func (this *PlatformMgr) LoadEntrySwitch() {
|
||||
//不使用etcd的情况下走api获取
|
||||
if model.GameParamData.UseEtcd {
|
||||
EtcdMgrSington.InitEntrySwitch()
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (this *PlatformMgr) Update() {
|
||||
|
||||
}
|
||||
|
@ -852,40 +594,5 @@ func CopyDBGameFreeField(src, dst *serverproto.DB_GameFree) {
|
|||
|
||||
func init() {
|
||||
ClockMgrSington.RegisteSinker(PlatformMgrSingleton)
|
||||
module.RegisteModule(PlatformMgrSingleton, time.Second*2, 0)
|
||||
|
||||
RegisterParallelLoadFunc("拉取平台数据", func() error {
|
||||
PlatformMgrSingleton.LoadPlatform()
|
||||
return nil
|
||||
})
|
||||
|
||||
RegisterParallelLoadFunc("拉取平台游戏开关", func() error {
|
||||
PlatformMgrSingleton.LoadGlobalGameStatus()
|
||||
return nil
|
||||
})
|
||||
|
||||
RegisterParallelLoadFunc("拉取游戏入口开关", func() error {
|
||||
PlatformMgrSingleton.LoadEntrySwitch()
|
||||
return nil
|
||||
})
|
||||
|
||||
RegisterParallelLoadFunc("拉取平台游戏详细配置", func() error {
|
||||
PlatformMgrSingleton.LoadPlatformGameFree()
|
||||
return nil
|
||||
})
|
||||
|
||||
RegisterParallelLoadFunc("平台包数据", func() error {
|
||||
PlatformMgrSingleton.LoadPlatformPackage()
|
||||
return nil
|
||||
})
|
||||
|
||||
RegisterParallelLoadFunc("平台公告", func() error {
|
||||
PlatformMgrSingleton.LoadCommonNotice()
|
||||
return nil
|
||||
})
|
||||
|
||||
RegisterParallelLoadFunc("平台比赛", func() error {
|
||||
PlatformMgrSingleton.LoadGameMatch()
|
||||
return nil
|
||||
})
|
||||
module.RegisteModule(PlatformMgrSingleton, time.Hour, 0)
|
||||
}
|
||||
|
|
|
@ -321,8 +321,6 @@ func (this *Player) OnLogined() {
|
|||
|
||||
this.BindGroupTag([]string{this.Platform})
|
||||
|
||||
PlatformMgrSingleton.PlayerLogin(this)
|
||||
|
||||
gameStateMgr.PlayerClear(this)
|
||||
|
||||
//玩家登录事件
|
||||
|
@ -416,8 +414,6 @@ func (this *Player) OnRehold() {
|
|||
//登录事件
|
||||
this.ReportLoginEvent()
|
||||
|
||||
PlatformMgrSingleton.PlayerLogin(this)
|
||||
|
||||
gameStateMgr.PlayerClear(this)
|
||||
|
||||
//玩家重连事件
|
||||
|
@ -527,7 +523,7 @@ func (this *Player) SendGameConfig(gameId int32, plf, chl string) {
|
|||
|
||||
gps := PlatformMgrSingleton.GetGameFrees(this.Platform)
|
||||
for _, v := range gps {
|
||||
if v.Status && PlatformMgrSingleton.GameStatus[v.DbGameFree.Id] {
|
||||
if v.Status && PlatformMgrSingleton.GetGlobalConfig().GameStatus[v.DbGameFree.Id] {
|
||||
if v.DbGameFree.GetGameRule() != 0 && v.DbGameFree.GetGameId() == gameId {
|
||||
// 场次配置
|
||||
lgc := &hall_proto.GameConfig1{
|
||||
|
@ -1524,7 +1520,6 @@ func (this *Player) DropLine() {
|
|||
this.SendToGame(int(server_proto.SSPacketID_PACKET_WG_PLAYERDROPLINE), pack)
|
||||
}
|
||||
PlayerMgrSington.DroplinePlayer(this)
|
||||
PlatformMgrSingleton.PlayerLogout(this)
|
||||
this.sid = 0
|
||||
this.gateSess = nil
|
||||
//统计在线时长日志
|
||||
|
@ -1554,7 +1549,6 @@ func (this *Player) Logout() {
|
|||
FriendMgrSington.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
//clubManager.DropLinePlayer(this.SnId)
|
||||
PlayerMgrSington.DroplinePlayer(this)
|
||||
PlatformMgrSingleton.PlayerLogout(this)
|
||||
if !this.IsRobot() {
|
||||
PlayerOnlineSington.Check = true
|
||||
}
|
||||
|
@ -1620,7 +1614,6 @@ func (this *Player) OnLogouted() {
|
|||
MatchSeasonMgrSington.SaveMatchSeasonData(this.SnId, true)
|
||||
}
|
||||
//平台数据
|
||||
PlatformMgrSingleton.PlayerLogout(this)
|
||||
//PlayerSingleAdjustMgr.DelPlayerData(this.Platform, this.SnId)
|
||||
|
||||
//离线玩家清空俱乐部信息
|
||||
|
@ -4373,12 +4366,7 @@ func (this *Player) BindTelReward() {
|
|||
}
|
||||
|
||||
func (this *Player) UpdateShopID(shopId int32) {
|
||||
var shopInfo *ShopInfo
|
||||
if shops, ok := ShopMgrSington.ShopInfos[this.Platform]; ok {
|
||||
if shopInf, ok := shops[shopId]; ok {
|
||||
shopInfo = shopInf
|
||||
}
|
||||
}
|
||||
var shopInfo = ShopMgrSington.ConfigMgr.GetShopInfo(this.Platform, shopId)
|
||||
if shopInfo != nil && shopInfo.FirstSwitch {
|
||||
if !slices.Contains(this.ShopID, int(shopInfo.Id)) {
|
||||
this.ShopID = append(this.ShopID, int(shopInfo.Id))
|
||||
|
|
|
@ -906,7 +906,6 @@ func (this *Scene) OnClose() {
|
|||
this.Broadcast(int(hallproto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
||||
|
||||
this.closed = true
|
||||
PlatformMgrSingleton.OnChangeSceneState(this, this.closed)
|
||||
this.sp.OnStop(this)
|
||||
//NpcServerAgentSington.OnSceneClose(this)
|
||||
for _, p := range this.players {
|
||||
|
@ -954,7 +953,6 @@ func (this *Scene) ForceDelete(isManual bool) {
|
|||
this.manualDelete = isManual
|
||||
this.deleting = true
|
||||
this.force = true
|
||||
PlatformMgrSingleton.OnChangeSceneState(this, this.force)
|
||||
pack := &serverproto.WGDestroyScene{
|
||||
SceneId: proto.Int(this.sceneId),
|
||||
}
|
||||
|
|
|
@ -86,48 +86,11 @@ const (
|
|||
)
|
||||
|
||||
var ShopMgrSington = &ShopMgr{
|
||||
ShopInfos: make(map[string]map[int32]*ShopInfo),
|
||||
ExShops: make(map[string]*webapi_proto.ExchangeShopList),
|
||||
ConfigMgr: model.NewConfigMgr(),
|
||||
}
|
||||
|
||||
type ShopMgr struct {
|
||||
ShopInfos map[string]map[int32]*ShopInfo // Platform:商品id:商品信息
|
||||
ExShops map[string]*webapi_proto.ExchangeShopList //兑换商品 消耗v卡
|
||||
}
|
||||
|
||||
type ShopInfo struct {
|
||||
Id int32 // 商品ID
|
||||
Page int32 // 页面 1,金币页面 2,钻石页面 3,道具页面
|
||||
Order int32 // 排序 页面内商品的位置排序
|
||||
Location []int32 // 显示位置 第1位,竖版大厅 第2位,Tienlen1级选场 第3位,捕鱼1级选场
|
||||
Picture string // 图片id
|
||||
Name string // 名称
|
||||
Label []int32 // 标签
|
||||
Ad int32 // 是否观看广告 0不看
|
||||
AdTime int32 // 观看几次广告
|
||||
RepeatTimes int32 // 领取次数
|
||||
CoolingTime []int32 // 观看冷却时间
|
||||
Type int32 // 获得类型 1,金币 2,钻石 3,道具类型
|
||||
Amount int64 // 获得数量
|
||||
AddArea []int32 // 加送百分比(比如加送10%,就配置110)
|
||||
ItemId int32 // 获得道具ID
|
||||
AddItemInfo []*shop.ItemInfo // 获得道具
|
||||
ConstType int32 // 购买消耗类型 1,金币 2,钻石 3,美金 4,柬埔寨币
|
||||
CostArea []int32 // 消耗数量区间
|
||||
VipLevel int32 //Vip等级限制
|
||||
Ratio int32 //权重
|
||||
EndTime int32 //新手礼包结束时间间隔
|
||||
//缓存数据
|
||||
AdLookedNum int32 //已经观看的次数
|
||||
AdReceiveNum int32 //已经领取的次数
|
||||
RemainingTime int32
|
||||
LastLookTime int32
|
||||
RoleAdded int32
|
||||
PetAdded int32
|
||||
RoleAddedId int32 //加成人物ID
|
||||
PetAddedId int32 //加成宠物ID
|
||||
FirstSwitch bool // 首冲翻倍
|
||||
AmountFinal int64 // 实际获得数量
|
||||
*model.ConfigMgr
|
||||
}
|
||||
|
||||
type ExchangeShopInfo struct {
|
||||
|
@ -150,55 +113,12 @@ func (this *ShopMgr) ModuleName() string {
|
|||
func (this *ShopMgr) Init() {
|
||||
}
|
||||
|
||||
// UpdateItemShop 更新商品信息
|
||||
func (this *ShopMgr) UpdateItemShop(cfgs *webapi_proto.ItemShopList) {
|
||||
if cfgs == nil {
|
||||
return
|
||||
}
|
||||
shopInfos := make(map[int32]*ShopInfo)
|
||||
for _, itemShop := range cfgs.List {
|
||||
var itemInfo []*shop.ItemInfo
|
||||
for key, value := range itemShop.Award {
|
||||
itemInfo = append(itemInfo, &shop.ItemInfo{
|
||||
ItemId: int32(key),
|
||||
ItemNum: value,
|
||||
})
|
||||
}
|
||||
|
||||
shopInfos[itemShop.Id] = &ShopInfo{
|
||||
Id: itemShop.Id,
|
||||
ItemId: itemShop.ItemId,
|
||||
Page: itemShop.Page,
|
||||
Order: itemShop.Order,
|
||||
Type: itemShop.Type,
|
||||
Location: itemShop.Location,
|
||||
Picture: itemShop.Picture,
|
||||
Name: itemShop.Name,
|
||||
Ad: itemShop.Ad,
|
||||
AdTime: itemShop.AdTime,
|
||||
RepeatTimes: itemShop.RepeatTimes,
|
||||
CoolingTime: itemShop.CoolingTime,
|
||||
Label: itemShop.Label,
|
||||
AddArea: itemShop.AddArea,
|
||||
Amount: int64(itemShop.Amount),
|
||||
ConstType: itemShop.ConstType,
|
||||
CostArea: itemShop.CostArea,
|
||||
AddItemInfo: itemInfo,
|
||||
VipLevel: itemShop.VipLevel,
|
||||
Ratio: itemShop.Ratio,
|
||||
EndTime: itemShop.EndTime,
|
||||
FirstSwitch: itemShop.FirstSwitch,
|
||||
}
|
||||
}
|
||||
this.ShopInfos[cfgs.Platform] = shopInfos
|
||||
}
|
||||
|
||||
// UpExShop 更新兑换商品信息
|
||||
func (this *ShopMgr) UpExShop(cfgs *webapi_proto.ExchangeShopList) {
|
||||
this.ExShops[cfgs.GetPlatform()] = cfgs
|
||||
this.GetConfig(cfgs.Platform).ExchangeShopList = cfgs
|
||||
}
|
||||
|
||||
func (this *ShopMgr) GetShopInfoProto(si *ShopInfo, p *Player, vipShopId int32) (shopInfo *shop.ShopInfo) {
|
||||
func (this *ShopMgr) GetShopInfoProto(si *model.ShopInfo, p *Player, vipShopId int32) (shopInfo *shop.ShopInfo) {
|
||||
if si == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -258,16 +178,11 @@ func (this *ShopMgr) GetShopInfoProto(si *ShopInfo, p *Player, vipShopId int32)
|
|||
}
|
||||
|
||||
// GetShopInfo 获取玩家某个商品信息(例如玩家看广告领取)
|
||||
func (this *ShopMgr) GetShopInfo(shopId int32, p *Player) *ShopInfo {
|
||||
func (this *ShopMgr) GetShopInfo(shopId int32, p *Player) *model.ShopInfo {
|
||||
if shopId == 0 {
|
||||
return nil
|
||||
}
|
||||
var shopInfo *ShopInfo
|
||||
if shops, ok := this.ShopInfos[p.Platform]; ok {
|
||||
if shopInf, ok1 := shops[shopId]; ok1 {
|
||||
shopInfo = shopInf
|
||||
}
|
||||
}
|
||||
var shopInfo = this.ConfigMgr.GetShopInfo(p.Platform, shopId)
|
||||
if shopInfo != nil {
|
||||
// AdLookedNum 已看次数
|
||||
// AdReceiveNum 已领次数
|
||||
|
@ -299,7 +214,7 @@ func (this *ShopMgr) GetShopInfo(shopId int32, p *Player) *ShopInfo {
|
|||
firstBuy = !slices.Contains(p.ShopID, int(shopInfo.Id))
|
||||
}
|
||||
|
||||
return &ShopInfo{
|
||||
return &model.ShopInfo{
|
||||
Id: shopInfo.Id,
|
||||
Ad: shopInfo.Ad,
|
||||
AdTime: shopInfo.AdTime,
|
||||
|
@ -347,7 +262,9 @@ func (this *ShopMgr) GetShopInfos(p *Player, nowLocation int) []*shop.ShopInfo {
|
|||
this.UpdateVipShopData(p)
|
||||
}
|
||||
|
||||
for _, shopInfo := range this.ShopInfos[p.Platform] {
|
||||
shopInfos := this.GetConfig(p.Platform).ShopInfos
|
||||
|
||||
for _, shopInfo := range shopInfos {
|
||||
if nowLocation == -1 || (nowLocation < len(shopInfo.Location) && shopInfo.Location[nowLocation] == 1) {
|
||||
if shopInfo.Page == ShopPageVip {
|
||||
continue
|
||||
|
@ -418,8 +335,14 @@ func (this *ShopMgr) GetShopInfos(p *Player, nowLocation int) []*shop.ShopInfo {
|
|||
}
|
||||
}
|
||||
//VIP商城数据
|
||||
if shopInfos == nil {
|
||||
return newShops
|
||||
}
|
||||
for i, data := range p.VipShopData {
|
||||
shopInfo := this.ShopInfos[p.Platform][data.Id]
|
||||
shopInfo := shopInfos[data.Id]
|
||||
if shopInfo == nil {
|
||||
continue
|
||||
}
|
||||
var AdLookedNum, AdReceiveNum, remainingTime int32
|
||||
var lastLookTime int64
|
||||
if shopInfo.Ad > 0 {
|
||||
|
@ -522,9 +445,9 @@ func (this *ShopMgr) UpdateVipShopData(p *Player) {
|
|||
return
|
||||
}
|
||||
//获取对应VIP等级物品列表
|
||||
vipShopInfoMap := make(map[int32]*ShopInfo)
|
||||
vipShopInfoMap := make(map[int32]*model.ShopInfo)
|
||||
var sumRatio = 0 //权重
|
||||
for _, shopInfo := range this.ShopInfos[p.Platform] {
|
||||
for _, shopInfo := range this.GetConfig(p.Platform).ShopInfos {
|
||||
if shopInfo.Page == ShopPageVip && shopInfo.VipLevel == p.VIP {
|
||||
vipShopInfoMap[shopInfo.Id] = shopInfo
|
||||
sumRatio += int(shopInfo.Ratio)
|
||||
|
@ -560,12 +483,7 @@ func (this *ShopMgr) UpdateVipShopData(p *Player) {
|
|||
|
||||
// LookAdReceive 看广告领取商品,校验领取次数
|
||||
func (this *ShopMgr) LookAdReceive(shopId int32, p *Player, position int32) shop.OpResultCode {
|
||||
var shopInfo *ShopInfo
|
||||
if shops, ok := this.ShopInfos[p.Platform]; ok {
|
||||
if shopInf, ok1 := shops[shopId]; ok1 {
|
||||
shopInfo = shopInf
|
||||
}
|
||||
}
|
||||
var shopInfo = this.ConfigMgr.GetShopInfo(p.Platform, shopId)
|
||||
if shopInfo == nil {
|
||||
logger.Logger.Errorf("this shop == nil shopId[%v] ", shopId)
|
||||
return shop.OpResultCode_OPRC_Error
|
||||
|
@ -585,7 +503,7 @@ func (this *ShopMgr) LookAdReceive(shopId int32, p *Player, position int32) shop
|
|||
}
|
||||
|
||||
// ReceiveVCPayShop 领取VC看广告商品
|
||||
func (this *ShopMgr) ReceiveVCPayShop(shopInfo *ShopInfo, p *Player, vipShopId, position int32) shop.OpResultCode {
|
||||
func (this *ShopMgr) ReceiveVCPayShop(shopInfo *model.ShopInfo, p *Player, vipShopId, position int32) shop.OpResultCode {
|
||||
if shopInfo == nil {
|
||||
logger.Logger.Errorf("this shop == nil")
|
||||
return shop.OpResultCode_OPRC_Error
|
||||
|
@ -596,7 +514,7 @@ func (this *ShopMgr) ReceiveVCPayShop(shopInfo *ShopInfo, p *Player, vipShopId,
|
|||
}
|
||||
|
||||
// PayAway 商城 领取商品
|
||||
func (this *ShopMgr) PayAway(shopInfo *ShopInfo, p *Player, vipShopId, position int32) {
|
||||
func (this *ShopMgr) PayAway(shopInfo *model.ShopInfo, p *Player, vipShopId, position int32) {
|
||||
shopName := shopInfo.Name + "|" + strconv.Itoa(int(shopInfo.Id))
|
||||
costNum := rand.Int31n(shopInfo.CostArea[1]-shopInfo.CostArea[0]+1) + shopInfo.CostArea[0]
|
||||
if shopInfo.Page == ShopPageVip {
|
||||
|
@ -713,12 +631,7 @@ func (this *ShopMgr) GetAmountFinal(p *Player, shopId, vipShopId int32) int64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
var shopInfo *ShopInfo
|
||||
if shops, ok := this.ShopInfos[p.Platform]; ok {
|
||||
if shopInf, ok := shops[shopId]; ok {
|
||||
shopInfo = shopInf
|
||||
}
|
||||
}
|
||||
var shopInfo = this.ConfigMgr.GetShopInfo(p.Platform, shopId)
|
||||
if shopInfo == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -769,7 +682,7 @@ func (this *ShopMgr) GetAmountFinal(p *Player, shopId, vipShopId int32) int64 {
|
|||
}
|
||||
|
||||
// 商城购买 额外增加道具
|
||||
func (this *ShopMgr) ShopAddItem(shopInfo *ShopInfo, p *Player) {
|
||||
func (this *ShopMgr) ShopAddItem(shopInfo *model.ShopInfo, p *Player) {
|
||||
if shopInfo.AddItemInfo != nil {
|
||||
for _, info := range shopInfo.AddItemInfo {
|
||||
item := &Item{ItemId: info.ItemId, ItemNum: info.ItemNum, ObtainTime: time.Now().Unix()}
|
||||
|
@ -784,7 +697,7 @@ func (this *ShopMgr) ShopAddItem(shopInfo *ShopInfo, p *Player) {
|
|||
}
|
||||
|
||||
// CreateVCOrder 产生VC订单,记录看广告获取商品的订单
|
||||
func (this *ShopMgr) CreateVCOrder(shopInfo *ShopInfo, snid, costNum int32, platform string, amount [3]int32) {
|
||||
func (this *ShopMgr) CreateVCOrder(shopInfo *model.ShopInfo, snid, costNum int32, platform string, amount [3]int32) {
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
//获得类型
|
||||
if shopInfo.Type < ShopTypeCoin && shopInfo.Type > ShopTypeItem {
|
||||
|
@ -811,7 +724,7 @@ func (this *ShopMgr) CreateVCOrder(shopInfo *ShopInfo, snid, costNum int32, plat
|
|||
}
|
||||
|
||||
func (this *ShopMgr) GetExchangeData(platform string, id int32) *ExchangeShopInfo {
|
||||
if exShops := this.ExShops[platform]; exShops != nil {
|
||||
if exShops := this.GetConfig(platform).ExchangeShopList; exShops != nil {
|
||||
for _, data := range exShops.List {
|
||||
if data.Id == id {
|
||||
var exType []*shop.ExchangeType
|
||||
|
@ -1126,7 +1039,10 @@ func (this *ShopMgr) ShopCheckShowRed(p *Player) {
|
|||
}
|
||||
for i := 0; i < 3; i++ {
|
||||
var isShow bool
|
||||
for _, shopInfo := range this.ShopInfos[p.Platform] {
|
||||
for _, shopInfo := range this.GetConfig(p.Platform).ShopInfos {
|
||||
if shopInfo == nil {
|
||||
continue
|
||||
}
|
||||
var AdLookedNum, remainingTime int32
|
||||
var lastLookTime int64
|
||||
if shopInfo.Ad > 0 && (i == -1 || (i < len(shopInfo.Location) && shopInfo.Location[i] == 1)) {
|
||||
|
@ -1171,7 +1087,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any,
|
|||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
var amount [ShopTypeItem]int32
|
||||
var dbShop *model.DbShop
|
||||
if shopInfo, ok := data.(*ShopInfo); ok {
|
||||
if shopInfo, ok := data.(*model.ShopInfo); ok {
|
||||
// 目前现金只能买钻石
|
||||
var addTotal = int64(shopInfo.Amount)
|
||||
added := rand.Int31n(shopInfo.AddArea[1]-shopInfo.AddArea[0]+1) + shopInfo.AddArea[0]
|
||||
|
|
|
@ -1538,7 +1538,7 @@ func init() {
|
|||
for _, s := range gameStatus {
|
||||
gameId := s.GetGameId()
|
||||
status := s.GetStatus()
|
||||
PlatformMgrSingleton.GameStatus[gameId] = status
|
||||
PlatformMgrSingleton.GetGlobalConfig().GameStatus[gameId] = status
|
||||
}
|
||||
pack.Tag = webapiproto.TagCode_SUCCESS
|
||||
pack.Msg = ""
|
||||
|
@ -1573,9 +1573,9 @@ func init() {
|
|||
for _, v := range dbGameFrees {
|
||||
dbGameFree := v.GetDbGameFree()
|
||||
logicId := dbGameFree.GetId()
|
||||
platform.PltGameCfg.games[logicId] = v
|
||||
platform.GameConfig.gameFreeId[logicId] = v
|
||||
}
|
||||
platform.PltGameCfg.RecreateCache()
|
||||
platform.GameConfig.Init()
|
||||
pack.Tag = webapiproto.TagCode_SUCCESS
|
||||
pack.Msg = ""
|
||||
return common.ResponseTag_Ok, pack
|
||||
|
@ -1726,7 +1726,7 @@ func init() {
|
|||
|
||||
// 首次购买现金商品,获得翻倍;标记商品已经购买过
|
||||
if addcoin+diamond > 0 {
|
||||
if m, ok := ShopMgrSington.ShopInfos[platform]; ok && m != nil {
|
||||
if m := ShopMgrSington.GetConfig(platform).ShopInfos; m != nil {
|
||||
if shopInfo, ok := m[msg.GetShopId()]; ok && shopInfo != nil {
|
||||
if shopInfo.FirstSwitch {
|
||||
if !slices.Contains(findPlayer.ShopID, int(msg.GetShopId())) {
|
||||
|
@ -4537,7 +4537,7 @@ func getPlayerDataParam(p *model.PlayerData, season *model.PlayerRankSeason) *mo
|
|||
return nil
|
||||
}
|
||||
|
||||
data := PlatformMgrSingleton.Get(p.Platform).PlayerPool
|
||||
data := PlatformMgrSingleton.GetConfig(p.Platform).PlayerPool
|
||||
|
||||
rankScore := make(map[int64]int64)
|
||||
if season == nil {
|
||||
|
|
|
@ -122,7 +122,7 @@ func (this *WelfareMgr) UpdateSign7(cfg *webapi_proto.Welfare7SignDateList) {
|
|||
if model.GameParamData.TestActSwitch {
|
||||
cfg.Switch = model.WelfareOpen
|
||||
}
|
||||
this.GetAllConfig(cfg.Platform).Welfare7SignDateList = cfg
|
||||
this.GetConfig(cfg.Platform).Welfare7SignDateList = cfg
|
||||
}
|
||||
|
||||
func (this *WelfareMgr) UpdateTurnplate(cfg *webapi_proto.WelfareTurnplateDateList) {
|
||||
|
@ -130,7 +130,7 @@ func (this *WelfareMgr) UpdateTurnplate(cfg *webapi_proto.WelfareTurnplateDateLi
|
|||
cfg.Switch = model.WelfareOpen
|
||||
}
|
||||
s := int32(0)
|
||||
info := this.GetAllConfig(cfg.Platform)
|
||||
info := this.GetConfig(cfg.Platform)
|
||||
if info.WelfareTurnplateDateList != nil {
|
||||
s = info.WelfareTurnplateDateList.Switch
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ func (this *WelfareMgr) UpdateBlindBox(cfg *webapi_proto.WelfareBlindBoxDataList
|
|||
cfg.Switch = model.WelfareOpen
|
||||
}
|
||||
s := int32(0)
|
||||
info := this.GetAllConfig(cfg.Platform)
|
||||
info := this.GetConfig(cfg.Platform)
|
||||
if info.WelfareBlindBoxDataList != nil {
|
||||
s = info.WelfareBlindBoxDataList.Switch
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func (this *WelfareMgr) UpdateFirstPay(cfg *webapi_proto.WelfareFirstPayDataList
|
|||
cfg.Switch = model.WelfareOpen
|
||||
}
|
||||
s := int32(0)
|
||||
info := this.GetAllConfig(cfg.Platform)
|
||||
info := this.GetConfig(cfg.Platform)
|
||||
if info.WelfareFirstPayDataList != nil {
|
||||
s = info.WelfareFirstPayDataList.Switch
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ func (this *WelfareMgr) UpdateContinuousPay(cfg *webapi_proto.WelfareContinuousP
|
|||
cfg.Switch = model.WelfareOpen
|
||||
}
|
||||
s := int32(0)
|
||||
info := this.GetAllConfig(cfg.Platform)
|
||||
info := this.GetConfig(cfg.Platform)
|
||||
if info.WelfareContinuousPayDataList != nil {
|
||||
s = info.WelfareContinuousPayDataList.Switch
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ func (this *WelfareMgr) UpdatePhoneLotteryStatus(cfg *webapi_proto.WelfarePhoneL
|
|||
cfg.Switch = model.WelfareOpen
|
||||
}
|
||||
s := int32(0)
|
||||
info := this.GetAllConfig(cfg.Platform)
|
||||
info := this.GetConfig(cfg.Platform)
|
||||
if info.WelfarePhoneLotteryStatus != nil {
|
||||
s = info.WelfarePhoneLotteryStatus.Switch
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ func (this *WelfareMgr) UpdatePhoneLotteryStatus(cfg *webapi_proto.WelfarePhoneL
|
|||
}
|
||||
|
||||
func (this *WelfareMgr) GetPhoneLotteryStatus(platform string) int32 {
|
||||
info := this.GetAllConfig(platform)
|
||||
info := this.GetConfig(platform)
|
||||
if info.WelfarePhoneLotteryStatus != nil {
|
||||
return info.WelfarePhoneLotteryStatus.Switch
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ func (this *WelfareMgr) UpdateCollectConfig(cfg *webapi_proto.WelfareCollectConf
|
|||
cfg.Switch = model.WelfareOpen
|
||||
}
|
||||
s := int32(0)
|
||||
info := this.GetAllConfig(cfg.Platform)
|
||||
info := this.GetConfig(cfg.Platform)
|
||||
if info.WelfareCollectConfig != nil {
|
||||
s = info.WelfareCollectConfig.Switch
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ func (this *WelfareMgr) UpdateCollectConfig(cfg *webapi_proto.WelfareCollectConf
|
|||
}
|
||||
|
||||
func (this *WelfareMgr) GetCollectSwitch(platform string) int32 {
|
||||
info := this.GetAllConfig(platform)
|
||||
info := this.GetConfig(platform)
|
||||
if info.WelfareCollectConfig != nil {
|
||||
return info.WelfareCollectConfig.Switch
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ func (this *WelfareMgr) OnDayChanged(player *Player) error {
|
|||
}
|
||||
|
||||
player.WelfData.ReliefFundTimes = 0
|
||||
blindBox := this.GetAllConfig(player.Platform).WelfareBlindBoxDataList
|
||||
blindBox := this.GetConfig(player.Platform).WelfareBlindBoxDataList
|
||||
if blindBox != nil { // 关闭循环重置为-1
|
||||
if blindBox.Cycle == model.WelfareClose && player.WelfData.BlindBoxId != 0 {
|
||||
player.WelfData.BlindBoxId = -1
|
||||
|
@ -293,7 +293,7 @@ func (this *WelfareMgr) GetTurnplate(p *Player) {
|
|||
pack := &welfare.SCGetTurnplate{
|
||||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||||
}
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
turnplate := info.WelfareTurnplateDateList
|
||||
sign7 := info.Welfare7SignDateList
|
||||
if turnplate != nil && sign7 != nil {
|
||||
|
@ -399,7 +399,7 @@ func (this *WelfareMgr) GetTurnplteVideo(p *Player) {
|
|||
p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack)
|
||||
}
|
||||
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
turn := info.WelfareTurnplateDateList // 转盘
|
||||
sign7 := info.Welfare7SignDateList // 签到
|
||||
if turn == nil || sign7 == nil {
|
||||
|
@ -578,7 +578,7 @@ func (this *WelfareMgr) GetAddupSign(p *Player, addupday int32) {
|
|||
pack := &welfare.SCGetAddupSign{
|
||||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||||
}
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
turnplate := info.WelfareTurnplateDateList
|
||||
sign7 := info.Welfare7SignDateList
|
||||
if turnplate != nil && sign7 != nil {
|
||||
|
@ -644,7 +644,7 @@ func (this *WelfareMgr) WelfaredInfo(p *Player) {
|
|||
pack := &welfare.SCWelfaredInfo{}
|
||||
diff := 0
|
||||
ts := time.Now().Unix()
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
turnplate := info.WelfareTurnplateDateList
|
||||
sign7 := info.Welfare7SignDateList
|
||||
if turnplate != nil && sign7 != nil {
|
||||
|
@ -720,7 +720,7 @@ func (this *WelfareMgr) WelfaredInfo(p *Player) {
|
|||
func (this *WelfareMgr) WelfareSwitch(p *Player, platform string, op int) {
|
||||
pack := &player_proto.SCEasyWelfaredInfo{}
|
||||
// 0转盘1盲盒2首冲3连续充值
|
||||
info := this.GetAllConfig(platform)
|
||||
info := this.GetConfig(platform)
|
||||
|
||||
// 转盘
|
||||
turnplate := info.WelfareTurnplateDateList
|
||||
|
@ -819,7 +819,7 @@ func (this *WelfareMgr) WelfareSwitch(p *Player, platform string, op int) {
|
|||
// Welfareturnplate 转盘红点
|
||||
func (this *WelfareMgr) Welfareturnplate(p *Player, op int32) bool { // 0 红点提示 1全部领取
|
||||
var isShow bool
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
turnplate := info.WelfareTurnplateDateList
|
||||
sign7 := info.Welfare7SignDateList
|
||||
if turnplate != nil && sign7 != nil {
|
||||
|
@ -884,7 +884,7 @@ func (this *WelfareMgr) BlindBoxInfo(p *Player, bid int32) {
|
|||
pack := &welfare.SCBlindBoxInfo{
|
||||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||||
}
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
blindBox := info.WelfareBlindBoxDataList
|
||||
if blindBox != nil {
|
||||
if blindBox.Switch != model.WelfareOpen {
|
||||
|
@ -960,7 +960,7 @@ func (this *WelfareMgr) BuyBlindBox(p *Player, buyid, ConfigPayId int32) {
|
|||
pack := &shop.SCPayInfo{
|
||||
RetCode: shop.OpResultCode_OPRC_Error,
|
||||
}
|
||||
blindBox := this.GetAllConfig(p.Platform).WelfareBlindBoxDataList
|
||||
blindBox := this.GetConfig(p.Platform).WelfareBlindBoxDataList
|
||||
if blindBox == nil {
|
||||
logger.Logger.Tracef("BuyBlindBox blindBox==nil snid: %v pack: %v", p.SnId, pack)
|
||||
p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack)
|
||||
|
@ -1062,7 +1062,7 @@ func (this *WelfareMgr) FirstPayInfo(p *Player) {
|
|||
pack := &welfare.SCWelfareFirstPayData{
|
||||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||||
}
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
firstPay := info.WelfareFirstPayDataList
|
||||
if firstPay != nil {
|
||||
pack.Switch = firstPay.Switch
|
||||
|
@ -1146,7 +1146,7 @@ func (this *WelfareMgr) BuyFirstPay(p *Player, ConfigPayId int32) {
|
|||
pack := &shop.SCPayInfo{
|
||||
RetCode: shop.OpResultCode_OPRC_Error,
|
||||
}
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
firstPay := info.WelfareFirstPayDataList
|
||||
if firstPay == nil {
|
||||
logger.Logger.Errorf("BuyFirstPay firstPay == nil snid: %v pack: %v", p.SnId, pack)
|
||||
|
@ -1271,7 +1271,7 @@ func (this *WelfareMgr) ContinuousPayInfo(p *Player) {
|
|||
pack := &welfare.SCWelfareContinuousPayData{
|
||||
OpRetCode: welfare.OpResultCode_OPRC_Error,
|
||||
}
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
continuousPay := info.WelfareContinuousPayDataList
|
||||
if continuousPay != nil {
|
||||
pack.Switch = continuousPay.Switch
|
||||
|
@ -1355,7 +1355,7 @@ func (this *WelfareMgr) BuyContinuousPay(p *Player, ConfigPayId int32) {
|
|||
pack := &shop.SCPayInfo{
|
||||
RetCode: shop.OpResultCode_OPRC_Error,
|
||||
}
|
||||
info := this.GetAllConfig(p.Platform)
|
||||
info := this.GetConfig(p.Platform)
|
||||
continuousPay := info.WelfareContinuousPayDataList
|
||||
if continuousPay == nil {
|
||||
logger.Logger.Tracef("BuyContinuousPay continuousPay == nil snid: %v pack: %v", p.SnId, pack)
|
||||
|
@ -1483,7 +1483,7 @@ func (this *WelfareMgr) Shutdown() {
|
|||
}
|
||||
|
||||
func (this *WelfareMgr) OnDayTimer() {
|
||||
for _, v := range this.ConfigMgr.Platform {
|
||||
for _, v := range this.GetConfigs() {
|
||||
v.BlindBoxCycle = 0
|
||||
v.FirstPayCycle = 0
|
||||
v.ContinuousPayCycle = 0
|
||||
|
|
Loading…
Reference in New Issue