优化
This commit is contained in:
parent
e9975bb591
commit
54f63eb812
@ -89,7 +89,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha
|
|||||||
if score >= v.ScoreLow && score <= v.ScoreUp {
|
if score >= v.ScoreLow && score <= v.ScoreUp {
|
||||||
for _, v1 := range v.RewardDrop {
|
for _, v1 := range v.RewardDrop {
|
||||||
reward := this.module.ModuleTools.GetGroupDataByLottery(v1, userinfo.Vip, userinfo.Lv)
|
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 {
|
if errdata = this.module.DispenseRes(session, reward, true); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -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)
|
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())
|
user, err := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
|
@ -250,7 +250,6 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
|
|||||||
// 检查是否命中双倍打造
|
// 检查是否命中双倍打造
|
||||||
for i := 0; i < int(req.Count); i++ {
|
for i := 0; i < int(req.Count); i++ {
|
||||||
res := this.module.ModuleTools.GetGroupDataByLottery(newdrop, user.Vip, user.Lv)
|
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 {
|
if ok := this.module.modelStove.CheckForgetwoEquip(req.ReelId, stove.Data[req.ReelId].Lv, addProbability); ok {
|
||||||
resReward = append(resReward, res...)
|
resReward = append(resReward, res...)
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,13 @@ type MCompConfigure struct {
|
|||||||
// 新掉落表
|
// 新掉落表
|
||||||
_group map[int64][]int32 // key 小组ID value cid
|
_group map[int64][]int32 // key 小组ID value cid
|
||||||
// 类型为1 的数据 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组
|
// 类型为1 的数据 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组
|
||||||
_lotteryType1 map[int32][]int32 // key 大组ID value cid
|
_lotteryType1 map[int32][]*cfg.GameLotteryData // key 大组ID value cid
|
||||||
// 类型为2 的数据 有多个小组ID
|
// 类型为2 的数据 有多个小组ID
|
||||||
_lotteryType2 map[int32][]int32 // key 大组ID value 小组ID
|
_lotteryType2 map[int32][]*cfg.GameLotteryData // key 大组ID value 小组ID
|
||||||
// 小组类型为1
|
// 小组类型为1
|
||||||
_groupType1 map[int64][]int32 //value cid
|
_groupType1 map[int64][]*cfg.GameLotteryData //value cid
|
||||||
// 小组类型为2
|
// 小组类型为2
|
||||||
_groupType2 map[int64][]int32 //value cid
|
_groupType2 map[int64][]*cfg.GameLotteryData //value cid
|
||||||
//Btype map[int32]int32
|
//Btype map[int32]int32
|
||||||
Stype map[int64]int32 // subtype
|
Stype map[int64]int32 // subtype
|
||||||
SNum map[int64]int32 // 小组产出数量
|
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_sign, cfg.NewGameSign, this.LoadSignData)
|
||||||
configure.RegisterConfigure(game_price, cfg.NewGamePricegroup, this.LoadPriceGroup)
|
configure.RegisterConfigure(game_price, cfg.NewGamePricegroup, this.LoadPriceGroup)
|
||||||
this._group = make(map[int64][]int32, 0)
|
this._group = make(map[int64][]int32, 0)
|
||||||
this._lotteryType1 = make(map[int32][]int32, 0)
|
this._lotteryType1 = make(map[int32][]*cfg.GameLotteryData, 0)
|
||||||
this._lotteryType2 = make(map[int32][]int32, 0)
|
this._lotteryType2 = make(map[int32][]*cfg.GameLotteryData, 0)
|
||||||
this._groupType1 = make(map[int64][]int32, 0)
|
this._groupType1 = make(map[int64][]*cfg.GameLotteryData, 0)
|
||||||
this._groupType2 = make(map[int64][]int32, 0)
|
this._groupType2 = make(map[int64][]*cfg.GameLotteryData, 0)
|
||||||
//this.Btype = make(map[int32]int32, 0)
|
//this.Btype = make(map[int32]int32, 0)
|
||||||
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)
|
||||||
|
|
||||||
|
this.GetGroupDataByLottery(50001001, 1, 1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,17 +99,14 @@ func (this *MCompConfigure) LoadGroupData() {
|
|||||||
this.hlock.Lock()
|
this.hlock.Lock()
|
||||||
defer this.hlock.Unlock()
|
defer this.hlock.Unlock()
|
||||||
this._group = make(map[int64][]int32, 0)
|
this._group = make(map[int64][]int32, 0)
|
||||||
this._lotteryType1 = make(map[int32][]int32, 0)
|
this._lotteryType1 = make(map[int32][]*cfg.GameLotteryData, 0)
|
||||||
this._lotteryType2 = make(map[int32][]int32, 0)
|
this._lotteryType2 = make(map[int32][]*cfg.GameLotteryData, 0)
|
||||||
this._groupType1 = make(map[int64][]int32, 0)
|
this._groupType1 = make(map[int64][]*cfg.GameLotteryData, 0)
|
||||||
this._groupType2 = make(map[int64][]int32, 0)
|
this._groupType2 = make(map[int64][]*cfg.GameLotteryData, 0)
|
||||||
//this.Btype = make(map[int32]int32, 0)
|
//this.Btype = make(map[int32]int32, 0)
|
||||||
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)
|
||||||
var tmp1 int64
|
|
||||||
var tmp2 int64
|
|
||||||
var itype int32
|
var itype int32
|
||||||
var subtype int32
|
|
||||||
var groupwt int32
|
var groupwt int32
|
||||||
var groupid int32
|
var groupid int32
|
||||||
for _, value := range configure.GetDataList() {
|
for _, value := range configure.GetDataList() {
|
||||||
@ -130,11 +128,6 @@ func (this *MCompConfigure) LoadGroupData() {
|
|||||||
groupwt = value.Groupwt
|
groupwt = value.Groupwt
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.Subtype == 0 {
|
|
||||||
value.Subtype = subtype
|
|
||||||
} else {
|
|
||||||
subtype = value.Subtype
|
|
||||||
}
|
|
||||||
// 数据安全校验
|
// 数据安全校验
|
||||||
if value.Min > value.Max {
|
if value.Min > value.Max {
|
||||||
log.Errorf("value.Min:%d > value.Max :%d ", 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 value.Type == 1 {
|
||||||
if tmp1 != key {
|
this._lotteryType1[value.Lotteryid] = append(this._lotteryType1[value.Lotteryid], value)
|
||||||
this._lotteryType1[value.Lotteryid] = append(this._lotteryType1[value.Lotteryid], value.Id)
|
|
||||||
tmp1 = key
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if value.Type == 2 {
|
if value.Type == 2 {
|
||||||
if tmp2 != key {
|
this._lotteryType2[value.Lotteryid] = append(this._lotteryType2[value.Lotteryid], value)
|
||||||
this._lotteryType2[value.Lotteryid] = append(this._lotteryType2[value.Lotteryid], value.Id)
|
|
||||||
tmp2 = key
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.Stype[key] == 1 { // 小组ID为1
|
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 {
|
} else if this.Stype[key] == 2 {
|
||||||
this._groupType2[key] = append(this._groupType2[key], value.Id)
|
this._groupType2[key] = append(this._groupType2[key], value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -199,11 +185,9 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
szID []int32 // 小组ID 数组
|
szID []int32 // 小组ID 数组
|
||||||
groupID int32
|
groupID int32
|
||||||
)
|
)
|
||||||
|
|
||||||
this.module.Debugf("config lotterId:%d, vipLv:%d, lv :%d", lotteryId, vipLv, lv)
|
this.module.Debugf("config lotterId:%d, vipLv:%d, lv :%d", lotteryId, vipLv, lv)
|
||||||
// 随机小组id
|
// 随机小组id
|
||||||
for _, v := range this._lotteryType1[lotteryId] {
|
for _, _data := 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.Playerlvmax == 0 || (_data.Playerlvmin <= lv && lv <= _data.Playerlvmax)) && (_data.VIPmax == 0 || (_data.VIPmin <= vipLv && vipLv <= _data.VIPmax)) { // 过滤等级等条件
|
||||||
if _data.Groupid != 0 {
|
if _data.Groupid != 0 {
|
||||||
szW = append(szW, _data.Groupwt)
|
szW = append(szW, _data.Groupwt)
|
||||||
@ -212,7 +196,6 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if len(szW) > 0 {
|
if len(szW) > 0 {
|
||||||
groupID = szID[comm.GetRandW(szW)] // 获得小组ID
|
groupID = szID[comm.GetRandW(szW)] // 获得小组ID
|
||||||
//fmt.Printf("大组类型为1的,获得小组ID :%d,dropID:%d", groupID, lotteryId)
|
//fmt.Printf("大组类型为1的,获得小组ID :%d,dropID:%d", groupID, lotteryId)
|
||||||
@ -221,15 +204,15 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
if this.Stype[key] == 1 { // 该小组的道具为权重掉落,必定从N个道具中随机出1个道具
|
if this.Stype[key] == 1 { // 该小组的道具为权重掉落,必定从N个道具中随机出1个道具
|
||||||
for i := 0; i < int(this.SNum[key]); i++ {
|
for i := 0; i < int(this.SNum[key]); i++ {
|
||||||
sztW := make([]int32, 0)
|
sztW := make([]int32, 0)
|
||||||
sztID := make([]int32, 0)
|
sztID := make([]*cfg.GameLotteryData, 0)
|
||||||
for _, v := range this._groupType1[key] {
|
for _, _data := range this._groupType1[key] {
|
||||||
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
|
|
||||||
sztW = append(sztW, _data.Itemwt)
|
sztW = append(sztW, _data.Itemwt)
|
||||||
sztID = append(sztID, _data.Id)
|
sztID = append(sztID, _data)
|
||||||
}
|
}
|
||||||
|
if len(sztW) == 0 {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
index := comm.GetRandW(sztW)
|
_data := sztID[comm.GetRandW(sztW)]
|
||||||
_data := this.GetLotterConfById(sztID[index])
|
|
||||||
count := comm.GetRandNum(_data.Min, _data.Max)
|
count := comm.GetRandNum(_data.Min, _data.Max)
|
||||||
// 随机获得的数量
|
// 随机获得的数量
|
||||||
items = append(items, &cfg.Gameatn{
|
items = append(items, &cfg.Gameatn{
|
||||||
@ -240,9 +223,7 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if this.Stype[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比)
|
} else if this.Stype[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比)
|
||||||
for _, v := range this._groupType2[key] {
|
for _, _data := range this._groupType2[key] {
|
||||||
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
|
|
||||||
|
|
||||||
if _data.Itemwt >= comm.GetRandNum(0, 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{
|
||||||
@ -251,7 +232,7 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
N: _data.Itemid.N * count, // 小组产出数量
|
N: _data.Itemid.N * count, // 小组产出数量
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -260,8 +241,7 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
// 每个小组id 都随机取一次
|
// 每个小组id 都随机取一次
|
||||||
szW = make([]int32, 0)
|
szW = make([]int32, 0)
|
||||||
szID = make([]int32, 0)
|
szID = make([]int32, 0)
|
||||||
for _, v := range this._lotteryType2[lotteryId] {
|
for _, _data := 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.Playerlvmax == 0 || (_data.Playerlvmin <= lv && lv <= _data.Playerlvmax)) && (_data.VIPmax == 0 || (_data.VIPmin <= vipLv && vipLv <= _data.VIPmax)) { // 过滤等级等条件
|
||||||
if _data.Groupid != 0 {
|
if _data.Groupid != 0 {
|
||||||
szW = append(szW, _data.Groupwt)
|
szW = append(szW, _data.Groupwt)
|
||||||
@ -269,7 +249,6 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 类型为2 可能会同时获得多个组id
|
// 类型为2 可能会同时获得多个组id
|
||||||
for pos, v := range szW {
|
for pos, v := range szW {
|
||||||
@ -279,16 +258,16 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
if this.Stype[key] == 1 { // 随机一组数据
|
if this.Stype[key] == 1 { // 随机一组数据
|
||||||
for i := 0; i < int(this.SNum[key]); i++ {
|
for i := 0; i < int(this.SNum[key]); i++ {
|
||||||
sztW := make([]int32, 0)
|
sztW := make([]int32, 0)
|
||||||
sztID := make([]int32, 0)
|
sztID := make([]*cfg.GameLotteryData, 0)
|
||||||
for _, v := range this._groupType1[key] {
|
for _, _data := range this._groupType1[key] {
|
||||||
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
|
|
||||||
sztW = append(sztW, _data.Itemwt)
|
sztW = append(sztW, _data.Itemwt)
|
||||||
sztID = append(sztID, _data.Id)
|
sztID = append(sztID, _data)
|
||||||
}
|
}
|
||||||
|
if len(sztW) > 0 {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
index := comm.GetRandW(sztW)
|
_data := sztID[comm.GetRandW(sztW)]
|
||||||
_data := this.GetLotterConfById(sztID[index])
|
|
||||||
//fmt.Printf("获得最终的道具 :%d", _data.Id)
|
|
||||||
count := comm.GetRandNum(_data.Min, _data.Max)
|
count := comm.GetRandNum(_data.Min, _data.Max)
|
||||||
// 随机获得的数量
|
// 随机获得的数量
|
||||||
items = append(items, &cfg.Gameatn{
|
items = append(items, &cfg.Gameatn{
|
||||||
@ -298,9 +277,7 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if this.Stype[key] == 2 {
|
} else if this.Stype[key] == 2 {
|
||||||
for _, v := range this._groupType2[key] {
|
for _, _data := range this._groupType2[key] {
|
||||||
if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值
|
|
||||||
|
|
||||||
if _data.Itemwt >= comm.GetRandNum(1, 1000) { // 命中
|
if _data.Itemwt >= comm.GetRandNum(1, 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{
|
||||||
@ -313,7 +290,6 @@ func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.module.Debugf("drop result:%v", items)
|
this.module.Debugf("drop result:%v", items)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -448,8 +424,7 @@ func (this *MCompConfigure) GetDropReward(dropId int32) (result []*cfg.Gameatn)
|
|||||||
for _, value := range data {
|
for _, value := range data {
|
||||||
szW = append(szW, value.P)
|
szW = append(szW, value.P)
|
||||||
}
|
}
|
||||||
index := comm.GetRandW(szW)
|
result = append(result, data[comm.GetRandW(szW)].Prize...)
|
||||||
result = append(result, data[index].Prize...)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user