This commit is contained in:
meixiongfeng 2023-09-27 21:06:20 +08:00
parent e9975bb591
commit 54f63eb812
4 changed files with 63 additions and 91 deletions

View File

@ -89,7 +89,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha
if score >= v.ScoreLow && score <= v.ScoreUp {
for _, v1 := range v.RewardDrop {
reward := this.module.ModuleTools.GetGroupDataByLottery(v1, userinfo.Vip, userinfo.Lv)
//reward := this.module.configure.GetDropReward(v1) // 获取掉落奖励
if errdata = this.module.DispenseRes(session, reward, true); errdata != nil {
return
}

View File

@ -114,7 +114,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
this.module.CheckRank(session.GetUserId(), req.BossType, req.Difficulty, req.Report)
}
// 发放通关随机奖励
//reward = this.module.configure.GetDropReward(cfgHunting.Drop) // 获取掉落奖励
user, err := this.module.ModuleUser.GetUser(session.GetUserId())
if err != nil {
errdata = &pb.ErrorData{

View File

@ -250,7 +250,6 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
// 检查是否命中双倍打造
for i := 0; i < int(req.Count); i++ {
res := this.module.ModuleTools.GetGroupDataByLottery(newdrop, user.Vip, user.Lv)
//res := this.module.configure.GetDropReward(newdrop)
if ok := this.module.modelStove.CheckForgetwoEquip(req.ReelId, stove.Data[req.ReelId].Lv, addProbability); ok {
resReward = append(resReward, res...)
}

View File

@ -44,13 +44,13 @@ type MCompConfigure struct {
// 新掉落表
_group map[int64][]int32 // key 小组ID value cid
// 类型为1 的数据 该大组中的小组为权重掉落必定从N个小组中随机出1个小组
_lotteryType1 map[int32][]int32 // key 大组ID value cid
_lotteryType1 map[int32][]*cfg.GameLotteryData // key 大组ID value cid
// 类型为2 的数据 有多个小组ID
_lotteryType2 map[int32][]int32 // key 大组ID value 小组ID
_lotteryType2 map[int32][]*cfg.GameLotteryData // key 大组ID value 小组ID
// 小组类型为1
_groupType1 map[int64][]int32 //value cid
_groupType1 map[int64][]*cfg.GameLotteryData //value cid
// 小组类型为2
_groupType2 map[int64][]int32 //value cid
_groupType2 map[int64][]*cfg.GameLotteryData //value cid
//Btype map[int32]int32
Stype map[int64]int32 // subtype
SNum map[int64]int32 // 小组产出数量
@ -80,15 +80,16 @@ func (this *MCompConfigure) Init(service core.IService, module core.IModule, com
configure.RegisterConfigure(game_sign, cfg.NewGameSign, this.LoadSignData)
configure.RegisterConfigure(game_price, cfg.NewGamePricegroup, this.LoadPriceGroup)
this._group = make(map[int64][]int32, 0)
this._lotteryType1 = make(map[int32][]int32, 0)
this._lotteryType2 = make(map[int32][]int32, 0)
this._groupType1 = make(map[int64][]int32, 0)
this._groupType2 = make(map[int64][]int32, 0)
this._lotteryType1 = make(map[int32][]*cfg.GameLotteryData, 0)
this._lotteryType2 = make(map[int32][]*cfg.GameLotteryData, 0)
this._groupType1 = make(map[int64][]*cfg.GameLotteryData, 0)
this._groupType2 = make(map[int64][]*cfg.GameLotteryData, 0)
//this.Btype = make(map[int32]int32, 0)
this.Stype = make(map[int64]int32, 0)
this.SNum = make(map[int64]int32, 0)
configure.RegisterConfigure(game_lottery, cfg.NewGameLottery, this.LoadGroupData)
this.GetGroupDataByLottery(50001001, 1, 1)
return
}
@ -98,17 +99,14 @@ func (this *MCompConfigure) LoadGroupData() {
this.hlock.Lock()
defer this.hlock.Unlock()
this._group = make(map[int64][]int32, 0)
this._lotteryType1 = make(map[int32][]int32, 0)
this._lotteryType2 = make(map[int32][]int32, 0)
this._groupType1 = make(map[int64][]int32, 0)
this._groupType2 = make(map[int64][]int32, 0)
this._lotteryType1 = make(map[int32][]*cfg.GameLotteryData, 0)
this._lotteryType2 = make(map[int32][]*cfg.GameLotteryData, 0)
this._groupType1 = make(map[int64][]*cfg.GameLotteryData, 0)
this._groupType2 = make(map[int64][]*cfg.GameLotteryData, 0)
//this.Btype = make(map[int32]int32, 0)
this.Stype = make(map[int64]int32, 0)
this.SNum = make(map[int64]int32, 0)
var tmp1 int64
var tmp2 int64
var itype int32
var subtype int32
var groupwt int32
var groupid int32
for _, value := range configure.GetDataList() {
@ -130,11 +128,6 @@ func (this *MCompConfigure) LoadGroupData() {
groupwt = value.Groupwt
}
if value.Subtype == 0 {
value.Subtype = subtype
} else {
subtype = value.Subtype
}
// 数据安全校验
if value.Min > value.Max {
log.Errorf("value.Min:%d > value.Max :%d ", value.Min, value.Max)
@ -157,23 +150,16 @@ func (this *MCompConfigure) LoadGroupData() {
}
if value.Type == 1 {
if tmp1 != key {
this._lotteryType1[value.Lotteryid] = append(this._lotteryType1[value.Lotteryid], value.Id)
tmp1 = key
}
this._lotteryType1[value.Lotteryid] = append(this._lotteryType1[value.Lotteryid], value)
}
if value.Type == 2 {
if tmp2 != key {
this._lotteryType2[value.Lotteryid] = append(this._lotteryType2[value.Lotteryid], value.Id)
tmp2 = key
}
this._lotteryType2[value.Lotteryid] = append(this._lotteryType2[value.Lotteryid], value)
}
if this.Stype[key] == 1 { // 小组ID为1
this._groupType1[key] = append(this._groupType1[key], value.Id)
this._groupType1[key] = append(this._groupType1[key], value)
} else if this.Stype[key] == 2 {
this._groupType2[key] = append(this._groupType2[key], value.Id)
this._groupType2[key] = append(this._groupType2[key], value)
}
}
return
@ -199,18 +185,15 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
szID []int32 // 小组ID 数组
groupID int32
)
this.module.Debugf("config lotterId:%d, vipLv:%d, lv :%d", lotteryId, vipLv, lv)
// 随机小组id
for _, v := range this._lotteryType1[lotteryId] {
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.Groupid != 0 {
szW = append(szW, _data.Groupwt)
szID = append(szID, _data.Groupid)
}
for _, _data := range this._lotteryType1[lotteryId] {
if (_data.Playerlvmax == 0 || (_data.Playerlvmin <= lv && lv <= _data.Playerlvmax)) && (_data.VIPmax == 0 || (_data.VIPmin <= vipLv && vipLv <= _data.VIPmax)) { // 过滤等级等条件
if _data.Groupid != 0 {
szW = append(szW, _data.Groupwt)
szID = append(szID, _data.Groupid)
}
}
}
if len(szW) > 0 {
@ -221,15 +204,15 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
if this.Stype[key] == 1 { // 该小组的道具为权重掉落必定从N个道具中随机出1个道具
for i := 0; i < int(this.SNum[key]); i++ {
sztW := make([]int32, 0)
sztID := make([]int32, 0)
for _, v := range this._groupType1[key] {
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
sztW = append(sztW, _data.Itemwt)
sztID = append(sztID, _data.Id)
}
sztID := make([]*cfg.GameLotteryData, 0)
for _, _data := range this._groupType1[key] {
sztW = append(sztW, _data.Itemwt)
sztID = append(sztID, _data)
}
index := comm.GetRandW(sztW)
_data := this.GetLotterConfById(sztID[index])
if len(sztW) == 0 {
continue
}
_data := sztID[comm.GetRandW(sztW)]
count := comm.GetRandNum(_data.Min, _data.Max)
// 随机获得的数量
items = append(items, &cfg.Gameatn{
@ -240,18 +223,16 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
}
} else if this.Stype[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比)
for _, v := range this._groupType2[key] {
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
if _data.Itemwt >= comm.GetRandNum(0, 1000) { // 命中
count := comm.GetRandNum(_data.Min, _data.Max)
items = append(items, &cfg.Gameatn{
A: _data.Itemid.A,
T: _data.Itemid.T,
N: _data.Itemid.N * count, // 小组产出数量
})
}
for _, _data := range this._groupType2[key] {
if _data.Itemwt >= comm.GetRandNum(0, 1000) { // 命中
count := comm.GetRandNum(_data.Min, _data.Max)
items = append(items, &cfg.Gameatn{
A: _data.Itemid.A,
T: _data.Itemid.T,
N: _data.Itemid.N * count, // 小组产出数量
})
}
}
}
@ -260,13 +241,11 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
// 每个小组id 都随机取一次
szW = make([]int32, 0)
szID = make([]int32, 0)
for _, v := range this._lotteryType2[lotteryId] {
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.Groupid != 0 {
szW = append(szW, _data.Groupwt)
szID = append(szID, _data.Groupid)
}
for _, _data := range this._lotteryType2[lotteryId] {
if (_data.Playerlvmax == 0 || (_data.Playerlvmin <= lv && lv <= _data.Playerlvmax)) && (_data.VIPmax == 0 || (_data.VIPmin <= vipLv && vipLv <= _data.VIPmax)) { // 过滤等级等条件
if _data.Groupid != 0 {
szW = append(szW, _data.Groupwt)
szID = append(szID, _data.Groupid)
}
}
}
@ -279,16 +258,16 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
if this.Stype[key] == 1 { // 随机一组数据
for i := 0; i < int(this.SNum[key]); i++ {
sztW := make([]int32, 0)
sztID := make([]int32, 0)
for _, v := range this._groupType1[key] {
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
sztW = append(sztW, _data.Itemwt)
sztID = append(sztID, _data.Id)
}
sztID := make([]*cfg.GameLotteryData, 0)
for _, _data := range this._groupType1[key] {
sztW = append(sztW, _data.Itemwt)
sztID = append(sztID, _data)
}
index := comm.GetRandW(sztW)
_data := this.GetLotterConfById(sztID[index])
//fmt.Printf("获得最终的道具 :%d", _data.Id)
if len(sztW) > 0 {
continue
}
_data := sztID[comm.GetRandW(sztW)]
count := comm.GetRandNum(_data.Min, _data.Max)
// 随机获得的数量
items = append(items, &cfg.Gameatn{
@ -298,17 +277,14 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
})
}
} else if this.Stype[key] == 2 {
for _, v := range this._groupType2[key] {
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
if _data.Itemwt >= comm.GetRandNum(1, 1000) { // 命中
count := comm.GetRandNum(_data.Min, _data.Max)
items = append(items, &cfg.Gameatn{
A: _data.Itemid.A,
T: _data.Itemid.T,
N: _data.Itemid.N * count, // 小组产出数量
})
}
for _, _data := range this._groupType2[key] {
if _data.Itemwt >= comm.GetRandNum(1, 1000) { // 命中
count := comm.GetRandNum(_data.Min, _data.Max)
items = append(items, &cfg.Gameatn{
A: _data.Itemid.A,
T: _data.Itemid.T,
N: _data.Itemid.N * count, // 小组产出数量
})
}
}
}
@ -448,8 +424,7 @@ func (this *MCompConfigure) GetDropReward(dropId int32) (result []*cfg.Gameatn)
for _, value := range data {
szW = append(szW, value.P)
}
index := comm.GetRandW(szW)
result = append(result, data[index].Prize...)
result = append(result, data[comm.GetRandW(szW)].Prize...)
return
}