秘境房间随机规则优化
This commit is contained in:
parent
e6c43b0520
commit
3de38ab74c
@ -41,15 +41,14 @@ type configureComp struct {
|
|||||||
// buff
|
// buff
|
||||||
buff map[int32]map[int32]struct{} // key buff 类型 value buffid
|
buff map[int32]map[int32]struct{} // key buff 类型 value buffid
|
||||||
// 房间随机
|
// 房间随机
|
||||||
_groupR map[int64][]int32 // key 小组ID value cid
|
|
||||||
// 类型为1 的数据 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组
|
// 类型为1 的数据 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组
|
||||||
_lotteryType1R map[int32][]int32 // key 大组ID value cid
|
_lotteryTypeR map[int32][]*cfg.GameRoomlotteryData // key 大组ID value cid
|
||||||
// 类型为2 的数据 有多个小组ID
|
// 类型为2 的数据 有多个小组ID
|
||||||
_lotteryType2R map[int32][]int32 // key 大组ID value 小组ID
|
_lotteryType2R map[int32][]*cfg.GameRoomlotteryData // key 大组ID value 小组ID
|
||||||
// 小组类型为1
|
// 小组类型为1
|
||||||
_groupType1R map[int64][]int32 //value cid
|
_groupType1R map[int64][]*cfg.GameRoomlotteryData //value cid
|
||||||
// 小组类型为2
|
// 小组类型为2
|
||||||
_groupType2R map[int64][]int32 //value cid
|
_groupType2R map[int64][]*cfg.GameRoomlotteryData //value cid
|
||||||
//Btype map[int32]int32
|
//Btype map[int32]int32
|
||||||
StypeR map[int64]int32 // subtype
|
StypeR map[int64]int32 // subtype
|
||||||
SNumR map[int64]int32 // 小组产出数量
|
SNumR map[int64]int32 // 小组产出数量
|
||||||
@ -101,6 +100,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
configure.RegisterConfigure(game_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff)
|
configure.RegisterConfigure(game_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff)
|
||||||
configure.RegisterConfigure(game_storyconf, cfg.NewGameStoneStory, this.LoadGameStoneStory)
|
configure.RegisterConfigure(game_storyconf, cfg.NewGameStoneStory, this.LoadGameStoneStory)
|
||||||
|
|
||||||
|
this.GetRoomGroupDataByLottery(110100)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,89 +171,68 @@ func (this *configureComp) LoadRoomGroupData() {
|
|||||||
if configure, ok := v.(*cfg.GameRoomlottery); ok {
|
if configure, ok := v.(*cfg.GameRoomlottery); ok {
|
||||||
this.hlock.Lock()
|
this.hlock.Lock()
|
||||||
defer this.hlock.Unlock()
|
defer this.hlock.Unlock()
|
||||||
this._groupR = make(map[int64][]int32, 0)
|
this._lotteryTypeR = make(map[int32][]*cfg.GameRoomlotteryData, 0)
|
||||||
this._lotteryType1R = make(map[int32][]int32, 0)
|
this._lotteryType2R = make(map[int32][]*cfg.GameRoomlotteryData, 0)
|
||||||
this._lotteryType2R = make(map[int32][]int32, 0)
|
this._groupType1R = make(map[int64][]*cfg.GameRoomlotteryData, 0)
|
||||||
this._groupType1R = make(map[int64][]int32, 0)
|
this._groupType2R = make(map[int64][]*cfg.GameRoomlotteryData, 0)
|
||||||
this._groupType2R = make(map[int64][]int32, 0)
|
|
||||||
//this.Btype = make(map[int32]int32, 0)
|
//this.Btype = make(map[int32]int32, 0)
|
||||||
this.StypeR = make(map[int64]int32, 0)
|
this.StypeR = make(map[int64]int32, 0)
|
||||||
this.SNumR = make(map[int64]int32, 0)
|
this.SNumR = make(map[int64]int32, 0)
|
||||||
var tmp1 int64
|
|
||||||
var tmp2 int64
|
|
||||||
var itype int32
|
var itype int32
|
||||||
var wt int32
|
var groupwt int32
|
||||||
var subid int32
|
var groupid int32
|
||||||
for _, value := range configure.GetDataList() {
|
for _, value := range configure.GetDataList() {
|
||||||
if value.SubGroupId == 0 {
|
if value.SubGroupId == 0 {
|
||||||
value.SubGroupId = subid
|
value.SubGroupId = groupid
|
||||||
} else {
|
} else {
|
||||||
subid = value.SubGroupId
|
groupid = value.SubGroupId
|
||||||
}
|
}
|
||||||
key := int64(value.GroupId)<<31 + int64(value.SubGroupId)
|
key := int64(value.GroupId)<<31 + int64(value.SubGroupId)
|
||||||
// key2 := int64(value.Lotteryid)<<31 + int64(value.Type)
|
|
||||||
this._groupR[key] = append(this._groupR[key], value.Id)
|
|
||||||
if value.GroupType == 0 {
|
if value.GroupType == 0 {
|
||||||
value.GroupType = itype
|
value.GroupType = itype
|
||||||
} else {
|
} else {
|
||||||
itype = value.GroupType
|
itype = value.GroupType
|
||||||
}
|
}
|
||||||
if value.SubGroupWt == 0 {
|
if value.SubGroupWt == 0 {
|
||||||
value.SubGroupWt = wt
|
value.SubGroupWt = groupwt
|
||||||
} else {
|
} else {
|
||||||
wt = value.SubGroupWt
|
groupwt = value.SubGroupWt
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := this.StypeR[key]; !ok {
|
if _, ok := this.StypeR[key]; !ok {
|
||||||
this.StypeR[key] = value.SubGroupType
|
this.StypeR[key] = value.GroupType
|
||||||
}
|
}
|
||||||
if _, ok := this.SNumR[key]; !ok {
|
if _, ok := this.SNumR[key]; !ok {
|
||||||
this.SNumR[key] = value.SubGroupNum
|
this.SNumR[key] = value.SubGroupNum //value.Groupnum
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.GroupType == 1 {
|
if value.GroupType == 1 {
|
||||||
if tmp1 != key {
|
this._lotteryTypeR[value.GroupId] = append(this._lotteryTypeR[value.GroupId], value)
|
||||||
this._lotteryType1R[value.GroupId] = append(this._lotteryType2R[value.GroupId], value.Id)
|
|
||||||
tmp1 = key
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if value.GroupType == 2 {
|
if value.GroupType == 2 {
|
||||||
if tmp2 != key {
|
this._lotteryType2R[value.GroupId] = append(this._lotteryType2R[value.GroupId], value)
|
||||||
this._lotteryType2R[value.GroupId] = append(this._lotteryType2R[value.GroupId], value.Id)
|
|
||||||
tmp2 = key
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.StypeR[key] == 1 { // 小组ID为1
|
if this.StypeR[key] == 1 { // 小组ID为1
|
||||||
this._groupType1R[key] = append(this._groupType1R[key], value.Id)
|
this._groupType1R[key] = append(this._groupType1R[key], value)
|
||||||
} else if this.StypeR[key] == 2 {
|
} else if this.StypeR[key] == 2 {
|
||||||
this._groupType2R[key] = append(this._groupType2R[key], value.Id)
|
this._groupType2R[key] = append(this._groupType2R[key], value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("get NewGameBufflottery conf err:%v", err)
|
log.Errorf("get LoadGroupData conf err:%v", err)
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (this *configureComp) GetRoomLotterConfById(id int32) (data *cfg.GameRoomlotteryData) {
|
|
||||||
|
|
||||||
if v, err := this.GetConfigure(game_roomlottery); err == nil {
|
|
||||||
if configure, ok := v.(*cfg.GameRoomlottery); ok {
|
|
||||||
data = configure.Get(id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 实际掉落逻辑 (传入 掉落组ID vip等级 玩家等级 返回获得的道具)
|
// 实际掉落逻辑 (传入 掉落组ID vip等级 玩家等级 返回获得的道具)
|
||||||
func (this *configureComp) GetRoomGroupDataByLottery(lotteryId int32) (rooms []int32) {
|
func (this *configureComp) GetRoomGroupDataByLottery(lotteryId int32) (rooms []int32) {
|
||||||
|
if _, ok := this._lotteryTypeR[lotteryId]; !ok {
|
||||||
if _, ok := this._lotteryType1R[lotteryId]; !ok {
|
|
||||||
if _, ok := this._lotteryType2R[lotteryId]; !ok {
|
if _, ok := this._lotteryType2R[lotteryId]; !ok {
|
||||||
this.module.Errorf("not found config lotterId:%d", lotteryId)
|
//this.module.Errorf("not found config lotterId:%d", lotteryId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,16 +242,14 @@ func (this *configureComp) GetRoomGroupDataByLottery(lotteryId int32) (rooms []i
|
|||||||
szID []int32 // 小组ID 数组
|
szID []int32 // 小组ID 数组
|
||||||
groupID int32
|
groupID int32
|
||||||
)
|
)
|
||||||
|
//this.module.Debugf("config lotterId:%d")
|
||||||
// 随机小组id
|
// 随机小组id
|
||||||
for _, v := range this._lotteryType1R[lotteryId] {
|
for _, _data := range this._lotteryTypeR[lotteryId] {
|
||||||
if _data := this.GetRoomLotterConfById(v); _data != nil {
|
if _data.SubGroupId != 0 {
|
||||||
if _data.SubGroupId == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
szW = append(szW, _data.SubGroupWt)
|
szW = append(szW, _data.SubGroupWt)
|
||||||
szID = append(szID, _data.SubGroupId)
|
szID = append(szID, _data.SubGroupId)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if len(szW) > 0 {
|
if len(szW) > 0 {
|
||||||
groupID = szID[comm.GetRandW(szW)] // 获得小组ID
|
groupID = szID[comm.GetRandW(szW)] // 获得小组ID
|
||||||
@ -282,39 +259,32 @@ func (this *configureComp) GetRoomGroupDataByLottery(lotteryId int32) (rooms []i
|
|||||||
if this.StypeR[key] == 1 { // 该小组的道具为权重掉落,必定从N个道具中随机出1个道具
|
if this.StypeR[key] == 1 { // 该小组的道具为权重掉落,必定从N个道具中随机出1个道具
|
||||||
for i := 0; i < int(this.SNumR[key]); i++ {
|
for i := 0; i < int(this.SNumR[key]); i++ {
|
||||||
sztW := make([]int32, 0)
|
sztW := make([]int32, 0)
|
||||||
sztID := make([]int32, 0)
|
sztID := make([]*cfg.GameRoomlotteryData, 0)
|
||||||
for _, v := range this._groupType1R[key] {
|
for _, _data := range this._groupType1R[key] {
|
||||||
if _data := this.GetRoomLotterConfById(v); _data != nil { // 权重赋值
|
sztW = append(sztW, _data.SubGroupWt)
|
||||||
sztW = append(sztW, _data.RoomWt)
|
sztID = append(sztID, _data)
|
||||||
sztID = append(sztID, _data.Id)
|
|
||||||
}
|
}
|
||||||
|
if len(sztW) == 0 {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
index := comm.GetRandW(sztW)
|
_data := sztID[comm.GetRandW(sztW)]
|
||||||
_data := this.GetRoomLotterConfById(sztID[index])
|
// 随机获得的数量
|
||||||
rooms = append(rooms, _data.RoomID)
|
rooms = append(rooms, _data.RoomID)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if this.StypeR[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比)
|
} else if this.StypeR[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比)
|
||||||
for _, v := range this._groupType2R[key] {
|
for _, _data := range this._groupType2R[key] {
|
||||||
if _data := this.GetRoomLotterConfById(v); _data != nil { // 权重赋值
|
|
||||||
|
|
||||||
if _data.RoomWt >= comm.GetRandNum(0, 1000) { // 命中
|
if _data.RoomWt >= comm.GetRandNum(0, 1000) { // 命中
|
||||||
rooms = append(rooms, _data.RoomID)
|
rooms = append(rooms, _data.RoomID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 每个小组id 都随机取一次
|
// 每个小组id 都随机取一次
|
||||||
szW = make([]int32, 0)
|
szW = make([]int32, 0)
|
||||||
szID = make([]int32, 0)
|
szID = make([]int32, 0)
|
||||||
for _, v := range this._lotteryType2R[lotteryId] {
|
for _, _data := range this._lotteryType2R[lotteryId] {
|
||||||
if _data := this.GetRoomLotterConfById(v); _data != nil {
|
if _data.SubGroupId != 0 {
|
||||||
if _data.SubGroupId == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
szW = append(szW, _data.SubGroupWt)
|
szW = append(szW, _data.SubGroupWt)
|
||||||
szID = append(szID, _data.SubGroupId)
|
szID = append(szID, _data.SubGroupId)
|
||||||
}
|
}
|
||||||
@ -328,23 +298,19 @@ func (this *configureComp) GetRoomGroupDataByLottery(lotteryId int32) (rooms []i
|
|||||||
if this.StypeR[key] == 1 { // 随机一组数据
|
if this.StypeR[key] == 1 { // 随机一组数据
|
||||||
for i := 0; i < int(this.SNumR[key]); i++ {
|
for i := 0; i < int(this.SNumR[key]); i++ {
|
||||||
sztW := make([]int32, 0)
|
sztW := make([]int32, 0)
|
||||||
sztID := make([]int32, 0)
|
sztID := make([]*cfg.GameRoomlotteryData, 0)
|
||||||
for _, v := range this._groupType1R[key] {
|
for _, _data := range this._groupType1R[key] {
|
||||||
if _data := this.GetRoomLotterConfById(v); _data != nil { // 权重赋值
|
|
||||||
sztW = append(sztW, _data.RoomWt)
|
sztW = append(sztW, _data.RoomWt)
|
||||||
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.GetRoomLotterConfById(sztID[index])
|
|
||||||
//fmt.Printf("获得最终的道具 :%d", _data.Id)
|
|
||||||
// 随机获得的数量
|
|
||||||
rooms = append(rooms, _data.RoomID)
|
rooms = append(rooms, _data.RoomID)
|
||||||
}
|
}
|
||||||
} else if this.StypeR[key] == 2 {
|
} else if this.StypeR[key] == 2 {
|
||||||
for _, v := range this._groupType2R[key] {
|
for _, _data := range this._groupType2R[key] {
|
||||||
if _data := this.GetRoomLotterConfById(v); _data != nil { // 权重赋值
|
|
||||||
|
|
||||||
if _data.RoomWt >= comm.GetRandNum(1, 1000) { // 命中
|
if _data.RoomWt >= comm.GetRandNum(1, 1000) { // 命中
|
||||||
rooms = append(rooms, _data.RoomID)
|
rooms = append(rooms, _data.RoomID)
|
||||||
}
|
}
|
||||||
@ -352,7 +318,7 @@ func (this *configureComp) GetRoomGroupDataByLottery(lotteryId int32) (rooms []i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
this.module.Debugf("drop rooms result:%v", rooms)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user