This commit is contained in:
liwei 2023-06-25 18:21:58 +08:00
commit 10c5a1d705

View File

@ -81,7 +81,6 @@ func (this *MCompConfigure) Init(service core.IService, module core.IModule, com
this.Stype = make(map[int64]int32, 0) this.Stype = make(map[int64]int32, 0)
this.SNum = make(map[int64]int32, 0) this.SNum = make(map[int64]int32, 0)
configure.RegisterConfigure(game_lottery, cfg.NewGameLottery, this.LoadGroupData) configure.RegisterConfigure(game_lottery, cfg.NewGameLottery, this.LoadGroupData)
return return
} }
@ -168,7 +167,7 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
// 随机小组id // 随机小组id
for _, v := range this._lotteryType1[lotteryId] { for _, v := range this._lotteryType1[lotteryId] {
if _data := this.GetLotterConfById(v); _data != nil { if _data := this.GetLotterConfById(v); _data != nil {
if (_data.Playerlvmax == 0 || _data.Playerlvmin <= lv && lv <= _data.Playerlvmax) && (_data.VIPmax == 0 || _data.VIPmin <= vipLv && vipLv <= _data.VIPmax) { // 过滤等级等条件 if (_data.Playerlvmax == 0 || (_data.Playerlvmin <= lv && lv <= _data.Playerlvmax)) && (_data.VIPmax == 0 || (_data.VIPmin <= vipLv && vipLv <= _data.VIPmax)) { // 过滤等级等条件
if _, ok := gourp[_data.Groupid]; !ok { if _, ok := gourp[_data.Groupid]; !ok {
gourp[_data.Groupid] = _data.Groupwt // 小组ID 权重赋值 gourp[_data.Groupid] = _data.Groupwt // 小组ID 权重赋值
szW = append(szW, _data.Groupwt) szW = append(szW, _data.Groupwt)
@ -211,7 +210,7 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
for _, v := range this._groupType2[key] { for _, v := range this._groupType2[key] {
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值 if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
fmt.Printf("大组类型1小组类型2获得道具 :%v, 该道具Cid:%d", _data.Itemid, v) fmt.Printf("大组类型1小组类型2获得道具 :%v, 该道具Cid:%d", _data.Itemid, v)
if _data.Itemwt >= comm.GetRandNum(1, 1000) { // 命中 if _data.Itemwt >= comm.GetRandNum(0, 1000) { // 命中
count := comm.GetRandNum(_data.Min, _data.Max) count := comm.GetRandNum(_data.Min, _data.Max)
items = append(items, &cfg.Gameatn{ items = append(items, &cfg.Gameatn{
A: _data.Itemid.A, A: _data.Itemid.A,
@ -226,19 +225,18 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
} else if this.Btype[lotteryId] == 2 { // 该大组中的小组为概率掉落,每个小组都会随机一次是否会掉落(单位为千分比) } else if this.Btype[lotteryId] == 2 { // 该大组中的小组为概率掉落,每个小组都会随机一次是否会掉落(单位为千分比)
// 每个小组id 都随机取一次 // 每个小组id 都随机取一次
var szGroupID []int32 // 获得的权重数组 var szGroupID []int32 // 获得的权重数组
gourp := make(map[int32]*cfg.GameLotteryData, 0) // key 小组ID value 权重 gourp := make([]*cfg.GameLotteryData, 0) // key 小组ID value 权重
for _, v := range this._lotteryType2[lotteryId] { for _, v := range this._lotteryType2[lotteryId] {
if _data := this.GetLotterConfById(v); _data != nil { if _data := this.GetLotterConfById(v); _data != nil {
if (_data.Playerlvmax == 0 || _data.Playerlvmin <= lv && lv <= _data.Playerlvmax) && (_data.VIPmax == 0 || _data.VIPmin <= vipLv && vipLv <= _data.VIPmax) { // 过滤等级等条件 if (_data.Playerlvmax == 0 || (_data.Playerlvmin <= lv && lv <= _data.Playerlvmax)) && (_data.VIPmax == 0 || (_data.VIPmin <= vipLv && vipLv <= _data.VIPmax)) { // 过滤等级等条件
if _, ok := gourp[_data.Groupid]; !ok { gourp = append(gourp, _data)
gourp[_data.Groupid] = _data // 小组ID 权重赋值
}
} }
} }
} }
// 类型为2 可能会同时获得多个组id // 类型为2 可能会同时获得多个组id
for k, v := range gourp { for _, v := range gourp {
k := v.Groupid
fmt.Printf("大组类型为2的,获得小组ID :%d,dropID:%d", k, v.Id) fmt.Printf("大组类型为2的,获得小组ID :%d,dropID:%d", k, v.Id)
if v.Itemwt >= comm.GetRandNum(0, 1000) { // 命中 if v.Itemwt >= comm.GetRandNum(0, 1000) { // 命中
szGroupID = append(szGroupID, k) szGroupID = append(szGroupID, k)