package base import ( "mongo.games.com/game/common" "mongo.games.com/game/srvdata" "mongo.games.com/goserver/core/logger" ) var SrvDataMgrEx = &SrvDataManagerEx{ DataReloader: make(map[string]SrvDataReloadInterface), } type SrvDataManagerEx struct { DataReloader map[string]SrvDataReloadInterface } func RegisterDataReloader(fileName string, sdri SrvDataReloadInterface) { SrvDataMgrEx.DataReloader[fileName] = sdri } type SrvDataReloadInterface interface { Reload() } // 奔驰宝马表格参数 var SystemChanceMgrEx = &PBDB_SystemChanceMgrEx{} type PBDB_SystemChanceMgrEx struct { RollCoinRate []int32 //赔率数组 RollCoinChance []int64 //概率数组 RollCoinIds []int32 } func (this *PBDB_SystemChanceMgrEx) Reload() { this.RollCoinIds = nil this.RollCoinRate = nil this.RollCoinChance = nil for _, value := range srvdata.PBDB_SystemChanceMgr.Datas.Arr { this.RollCoinIds = append(this.RollCoinIds, value.GetId()) this.RollCoinRate = append(this.RollCoinRate, value.GetCoin()) this.RollCoinChance = append(this.RollCoinChance, int64(value.GetId()), int64(value.GetRate())) } logger.Logger.Trace(this) } func (this *PBDB_SystemChanceMgrEx) GetRollCoinIds() []int32 { var rollCoinIds = []int32{} for _, value := range SystemChanceMgrEx.RollCoinIds { rollCoinIds = append(rollCoinIds, value) } for i := 0; i < len(rollCoinIds); i++ { rollIndex := common.RandInt(len(rollCoinIds)) rollCoinIds[i], rollCoinIds[rollIndex] = rollCoinIds[rollIndex], rollCoinIds[i] } return rollCoinIds } ////飞禽走兽表格参数 //var AnimalsChanceMgrEx = &PBDB_AnimalsChanceMgrEx{} // //type PBDB_AnimalsChanceMgrEx struct { // RollAnimalsIds []int64 // //RollAnimalsOdds []int64 //赔率数组 // RollAnimalsOdds map[int64]int64 // RollAnimalsRate []int64 //概率数组 (id,rate) //} // //func (this *PBDB_AnimalsChanceMgrEx) Reload() { // this.RollAnimalsIds = nil // this.RollAnimalsOdds = make(map[int64]int64) // this.RollAnimalsRate = nil // for _, value := range srvdata.PBDB_AnimalsChanceMgr.Datas.Arr { // this.RollAnimalsIds = append(this.RollAnimalsIds, int64(value.GetId())) // this.RollAnimalsOdds[int64(value.GetId())] = int64(value.GetCoin()[0]) // this.RollAnimalsRate = append(this.RollAnimalsRate, int64(value.GetId()), int64(value.GetRateA())) // if int64(value.GetId()) == int64(rollanimals.RollAnimals_Shark) { // this.RollAnimalsOdds[int64(rollanimals.RollAnimals_Big_Shark)] = int64(value.GetCoin()[1]) // } // } // this.RollAnimalsOdds[int64(rollanimals.RollAnimals_Bird)] = int64(rollanimals.RollAnimals_BirdOdds) // this.RollAnimalsOdds[int64(rollanimals.RollAnimals_Beast)] = int64(rollanimals.RollAnimals_BeastOdds) // // logger.Logger.Trace(this) //} // 深林舞会表格参数 var AnimalColorMgrEx = &DB_AnimalColorMgrEx{make(map[int32][]int32)} type DB_AnimalColorMgrEx struct { RollColorRate map[int32][]int32 //赔率数组 } func (this *DB_AnimalColorMgrEx) Reload() { for _, value := range srvdata.PBDB_AnimalColorMgr.Datas.Arr { this.RollColorRate[value.GetId()] = value.GetColorChance() } for key, value := range this.RollColorRate { if len(value) != 13 { logger.Logger.Error("Animal color data reload error.") this.RollColorRate[key] = []int32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} } } } var FishTemplateEx = &DB_FishMgrEx{FishPool: make(map[int32]*FishTemplate)} // 初始化鱼模板 type FishTemplate struct { ID int32 //鱼的模板ID Name string //鱼的昵称 Exp int32 //鱼的基础经验 DropCoin []int32 //鱼掉落的基础金币数 Boss int32 //BOSS Speed int32 //速度 HP []int32 //血量 Ratio int32 //底分系数 Ratio1 []int32 //激光炮掉血比例 FishType int32 //鱼本身的分类 RandomCoin string //掉落金币的倍数权重 Rate int32 //概率 大闹天宫尝试 Jackpot int32 //奖金鱼概率(天天捕鱼) DealRate int32 //致命一击概率(天天捕鱼) IsBoss int32 //是否是BOSS鱼 Gold []int32 //金币 EXP int32 //经验 } type DB_FishMgrEx struct { FishPool map[int32]*FishTemplate // 鱼id:鱼配置文件 } func (this *DB_FishMgrEx) Reload() { for _, value := range srvdata.PBDB_FishMgr.Datas.Arr { ft := &FishTemplate{} ft.ID = value.GetId() ft.Name = value.GetName() ft.Exp = value.GetExp() ft.Boss = value.GetIsBoss() ft.Speed = value.GetSpeed() ft.FishType = value.GetFishType() ft.RandomCoin = value.GetRandomCoin() ft.Rate = value.GetRate() ft.IsBoss = value.GetIsBoss() ft.Gold = value.Gold ft.EXP = value.Exp this.FishPool[value.GetId()] = ft } } var FishOutEx = &DB_FishOutMgrEx{FishOutPool: make(map[int32]*AppearFish)} // 初始化鱼模板 type AppearFish struct { FishId int32 //对应fish表中的fishType Name string //鱼的名字 Exp int32 //经验值 Multiple []int32 //倍数 Prob float64 //死亡概率 目前不用 看后期设计 每个场次单独控制 还是整体控制 BaseRates float64 //基础概率 目前不用 Path []int32 //出鱼路径 FishNum []int32 //出鱼数量 Interval int32 //出鱼间隔 SceneType int32 Event int32 //鱼事件 } type DB_FishOutMgrEx struct { FishOutPool map[int32]*AppearFish // 鱼id:鱼配置文件 } // 出鱼策略初始化 func (this *DB_FishOutMgrEx) InitFishAppear() { this.FishOutPool = make(map[int32]*AppearFish) for _, v := range srvdata.PBDB_FishOutMgr.Datas.Arr { //logger.Logger.Tracef("初始化房间出鱼列表 fishId = %v", v.Id) this.FishOutPool[v.Id] = &AppearFish{ FishId: v.Id, Exp: v.Exp, Multiple: v.Multiple, Path: v.Path, Name: v.Name, Interval: v.RefreshInterval, FishNum: v.Count, SceneType: v.SceneType, Event: v.Event, } } }