Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
74c650b409
@ -95,6 +95,7 @@ const (
|
|||||||
ModuleDailytask core.M_Modules = "dailytask" //每日任务
|
ModuleDailytask core.M_Modules = "dailytask" //每日任务
|
||||||
ModuleQuestionnaire core.M_Modules = "questionnaire" //问卷调查
|
ModuleQuestionnaire core.M_Modules = "questionnaire" //问卷调查
|
||||||
ModuleMainline core.M_Modules = "mainline" //主线模块
|
ModuleMainline core.M_Modules = "mainline" //主线模块
|
||||||
|
ModuleStone core.M_Modules = "stonehenge"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 数据表名定义处
|
// 数据表名定义处
|
||||||
|
60
modules/stonehenge/api_challenge.go
Normal file
60
modules/stonehenge/api_challenge.go
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package stonehenge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.StonehengeBattleReq) (errdata *pb.ErrorData) {
|
||||||
|
if req.Eventid == 0 {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ReqParameterError,
|
||||||
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
///挑战主线关卡
|
||||||
|
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StonehengeBattleReq) (errdata *pb.ErrorData) {
|
||||||
|
var (
|
||||||
|
conf *cfg.GameStoneEventData
|
||||||
|
err error
|
||||||
|
battleConf *cfg.GameStoneBattleData
|
||||||
|
)
|
||||||
|
if conf, err = this.module.configure.GetStoneEventDataById(req.Eventid); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if battleConf, err = this.module.configure.GetBattleConfById(conf.Value1); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if errdata = this.ChallengeCheck(session, req); errdata != nil {
|
||||||
|
return // 参数校验失败直接返回
|
||||||
|
}
|
||||||
|
errdata, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||||
|
Ptype: pb.PlayType_mainline,
|
||||||
|
Title: "",
|
||||||
|
Format: req.Battle,
|
||||||
|
Mformat: battleConf.FormatList,
|
||||||
|
})
|
||||||
|
if errdata != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.module.GetType()), "battle", &pb.StonehengeBattleResp{
|
||||||
|
Eventid: req.Eventid,
|
||||||
|
Info: &pb.BattleInfo{Id: record.Id, Title: record.Title, Rulesid: battleConf.BattleReadyID, Btype: record.Btype, Ptype: record.Ptype, RedCompId: record.RedCompId, Redflist: record.Redflist, BlueCompId: record.BlueCompId, Buleflist: record.Buleflist},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
84
modules/stonehenge/api_challengeover.go
Normal file
84
modules/stonehenge/api_challengeover.go
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
package stonehenge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 参数校验
|
||||||
|
func (this *apiComp) BattleOverCheck(session comm.IUserSession, req *pb.StonehengeBattleOverReq) (errdata *pb.ErrorData) {
|
||||||
|
if req.Eventid == 0 {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ReqParameterError,
|
||||||
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// /挑战主线关卡
|
||||||
|
func (this *apiComp) BattleOver(session comm.IUserSession, req *pb.StonehengeBattleOverReq) (errdata *pb.ErrorData) {
|
||||||
|
var (
|
||||||
|
isWin bool
|
||||||
|
update map[string]interface{}
|
||||||
|
roomConf *cfg.GameStoneRoomData
|
||||||
|
eventConf *cfg.GameStoneEventData
|
||||||
|
newEvent int32 // 是否有新的事件
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
errdata, isWin = this.module.battle.CheckBattleReport(session, req.Report)
|
||||||
|
if errdata != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !isWin {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
update = make(map[string]interface{})
|
||||||
|
stone := this.module.modelStonehenge.GetStonehengeData(session.GetUserId())
|
||||||
|
if _, ok := stone.Rooms.Eventid[req.Eventid]; !ok { // 不存在该事件
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ReqParameterError,
|
||||||
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||||
|
Message: fmt.Sprintf("req.Eventid err :%d", req.Eventid),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if stone.Rooms.Eventid[req.Eventid] { // 重复完成
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_StonehengeRepeatedReward,
|
||||||
|
Title: pb.ErrorCode_StonehengeRepeatedReward.ToString(),
|
||||||
|
Message: fmt.Sprintf("req.Eventid err :%d", req.Eventid),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
update["stageID"] = stone.StageID
|
||||||
|
if roomConf, err = this.module.configure.GetStoneRoomDataById(stone.Rooms.Roomid); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if eventConf, err = this.module.configure.GetStoneEventDataById(req.Eventid); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 校验事件有后续事件
|
||||||
|
if eventConf.Probability >= comm.GetRandNum(0, 1000) { // 命中
|
||||||
|
newEvent = eventConf.PostEvent
|
||||||
|
stone.Rooms.Eventid[newEvent] = false //
|
||||||
|
stone.Rooms.Eventid[req.Eventid] = true //
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验是否通关
|
||||||
|
for _, v := range roomConf.Condition {
|
||||||
|
if v == eventConf.EventType {
|
||||||
|
stone.Rooms.Complete = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update["rooms"] = stone.Rooms
|
||||||
|
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||||
|
session.SendMsg(string(this.module.GetType()), "battleover", &pb.StonehengeBattleOverResp{}) // 数据推送
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
@ -30,6 +30,7 @@ func (this *apiComp) EnterLevel(session comm.IUserSession, req *pb.StonehengeEnt
|
|||||||
roomConf *cfg.GameStoneRoomData
|
roomConf *cfg.GameStoneRoomData
|
||||||
szBuff []int32
|
szBuff []int32
|
||||||
err error
|
err error
|
||||||
|
szEvent []int32
|
||||||
)
|
)
|
||||||
update = make(map[string]interface{})
|
update = make(map[string]interface{})
|
||||||
if errdata = this.EnterLevelCheck(session, req); errdata != nil {
|
if errdata = this.EnterLevelCheck(session, req); errdata != nil {
|
||||||
@ -94,14 +95,32 @@ func (this *apiComp) EnterLevel(session comm.IUserSession, req *pb.StonehengeEnt
|
|||||||
if roomConf, err = this.module.configure.GetStoneRoomDataById(portal); err != nil {
|
if roomConf, err = this.module.configure.GetStoneRoomDataById(portal); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if roomConf.EventrewardGroup != 0 { // 参数校验
|
if roomConf.EventrewardGroup != 0 { // 垃圾事件组
|
||||||
szBuff = this.module.configure.GetEventGroupDataByLottery(roomConf.EventrewardGroup)
|
szEvent = append(szEvent, roomConf.EventrewardGroup)
|
||||||
|
|
||||||
|
}
|
||||||
|
if roomConf.EventBattleGroup != 0 { // 战斗事件组
|
||||||
|
szEvent = append(szEvent, roomConf.EventBattleGroup)
|
||||||
|
}
|
||||||
|
if roomConf.EventStoryNpcGroup != 0 { // 剧情NPC事件组
|
||||||
|
szEvent = append(szEvent, roomConf.EventStoryNpcGroup)
|
||||||
|
}
|
||||||
|
if roomConf.EventTreasureGroup != 0 { // 宝箱奖励事件组
|
||||||
|
szEvent = append(szEvent, roomConf.EventTreasureGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
if roomConf.EventStoreGroup != 0 { // 商店事件组
|
||||||
|
szEvent = append(szEvent, roomConf.EventStoreGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(szEvent) > 0 {
|
||||||
|
szBuff = this.module.configure.GetEventGroupDataByLottery(szEvent...)
|
||||||
for _, v := range szBuff {
|
for _, v := range szBuff {
|
||||||
stone.Rooms.Eventid[v] = true
|
stone.Rooms.Eventid[v] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update["rooms"] = stone.Rooms
|
update["rooms"] = stone.Rooms
|
||||||
|
stone.CurRoomIndes = 1 // 第一次进房间 默认第一关
|
||||||
update["curRoomIndes"] = stone.CurRoomIndes
|
update["curRoomIndes"] = stone.CurRoomIndes
|
||||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||||
session.SendMsg(string(this.module.GetType()), "enterlevel", &pb.StonehengeEnterLevelResp{
|
session.SendMsg(string(this.module.GetType()), "enterlevel", &pb.StonehengeEnterLevelResp{
|
||||||
|
@ -31,12 +31,13 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.StonehengeFinishR
|
|||||||
stone.Rooms = &pb.RoomData{}
|
stone.Rooms = &pb.RoomData{}
|
||||||
update["rooms"] = stone.Rooms
|
update["rooms"] = stone.Rooms
|
||||||
stone.Webuff = make([]int32, 0)
|
stone.Webuff = make([]int32, 0)
|
||||||
update["envbuff"] = stone.Webuff
|
update["webuff"] = stone.Webuff
|
||||||
stone.Enemybuff = make([]int32, 0)
|
stone.Enemybuff = make([]int32, 0)
|
||||||
update["enemybuff"] = stone.Enemybuff
|
update["enemybuff"] = stone.Enemybuff
|
||||||
|
stone.Userbuff = make(map[int32]int32)
|
||||||
|
update["userbuff"] = stone.Userbuff
|
||||||
stone.Hero = make([]*pb.BattleRole, 0)
|
stone.Hero = make([]*pb.BattleRole, 0)
|
||||||
update["hero"] = stone.Hero
|
update["hero"] = stone.Hero
|
||||||
|
|
||||||
stone.Addweight = make(map[int32]int32, 0)
|
stone.Addweight = make(map[int32]int32, 0)
|
||||||
update["addweight"] = stone.Addweight
|
update["addweight"] = stone.Addweight
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.StonehengeG
|
|||||||
func (this *apiComp) GetList(session comm.IUserSession, req *pb.StonehengeGetListReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.StonehengeGetListReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
stone *pb.DBStonehenge
|
stone *pb.DBStonehenge
|
||||||
|
rooms []int32
|
||||||
)
|
)
|
||||||
if errdata = this.GetListCheck(session, req); errdata != nil {
|
if errdata = this.GetListCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
@ -31,20 +32,27 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.StonehengeGetLis
|
|||||||
stone.Rooms = &pb.RoomData{}
|
stone.Rooms = &pb.RoomData{}
|
||||||
update["rooms"] = stone.Rooms
|
update["rooms"] = stone.Rooms
|
||||||
stone.Webuff = make([]int32, 0)
|
stone.Webuff = make([]int32, 0)
|
||||||
update["envbuff"] = stone.Webuff
|
update["webuff"] = stone.Webuff
|
||||||
stone.Enemybuff = make([]int32, 0)
|
stone.Enemybuff = make([]int32, 0)
|
||||||
update["enemybuff"] = stone.Enemybuff
|
update["enemybuff"] = stone.Enemybuff
|
||||||
|
stone.Userbuff = make(map[int32]int32)
|
||||||
|
update["userbuff"] = stone.Userbuff
|
||||||
stone.Hero = make([]*pb.BattleRole, 0)
|
stone.Hero = make([]*pb.BattleRole, 0)
|
||||||
update["hero"] = stone.Hero
|
update["hero"] = stone.Hero
|
||||||
|
|
||||||
stone.Addweight = make(map[int32]int32, 0)
|
stone.Addweight = make(map[int32]int32, 0)
|
||||||
update["addweight"] = stone.Addweight
|
update["addweight"] = stone.Addweight
|
||||||
|
|
||||||
stone.Etime = utils.WeekIntervalTime(0)
|
stone.Etime = utils.WeekIntervalTime(0)
|
||||||
update["etime"] = stone.Etime
|
update["etime"] = stone.Etime
|
||||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||||
}
|
}
|
||||||
|
s := &DBStoneBoss{}
|
||||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.StonehengeGetListResp{Data: stone})
|
this.module.ModuleTools.GetGlobalData(StoneBossKey, s)
|
||||||
|
for _, v := range s.BossStage {
|
||||||
|
rooms = append(rooms, v.Roomid)
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.module.GetType()), "getlist", &pb.StonehengeGetListResp{
|
||||||
|
Data: stone,
|
||||||
|
Roomid: rooms,
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,22 @@ func (this *apiComp) GotoRoom(session comm.IUserSession, req *pb.StonehengeGotoR
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
stone.CurRoomIndes += 1
|
stone.CurRoomIndes += 1
|
||||||
|
|
||||||
update["curRoomIndes"] = stone.CurRoomIndes
|
update["curRoomIndes"] = stone.CurRoomIndes
|
||||||
stone.Rooms = &pb.RoomData{
|
stone.Rooms = &pb.RoomData{
|
||||||
Eventid: map[int32]bool{},
|
Eventid: map[int32]bool{},
|
||||||
|
Roomid: req.Portal,
|
||||||
|
Index: stone.CurRoomIndes,
|
||||||
}
|
}
|
||||||
stone.Rooms.Portal = this.module.configure.GetRoomGroupDataByLottery(req.Portal)
|
stone.Rooms.Portal = this.module.configure.GetRoomGroupDataByLottery(req.Portal)
|
||||||
|
// 校验是否进boss
|
||||||
|
if this.module.configure.GetFloorConfByStageId(stone.StageID)-1 == stone.CurRoomIndes {
|
||||||
|
s := &DBStoneBoss{}
|
||||||
|
this.module.ModuleTools.GetGlobalData(StoneBossKey, s)
|
||||||
|
if v, ok := s.BossStage[stone.StageID]; ok {
|
||||||
|
stone.Rooms.Portal = []int32{v.Roomid}
|
||||||
|
}
|
||||||
|
}
|
||||||
update["rooms"] = stone.Rooms
|
update["rooms"] = stone.Rooms
|
||||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||||
session.SendMsg(string(this.module.GetType()), "gotoroom", &pb.StonehengeGotoRoomResp{})
|
session.SendMsg(string(this.module.GetType()), "gotoroom", &pb.StonehengeGotoRoomResp{})
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package stonehenge
|
package stonehenge
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
@ -20,6 +19,7 @@ const (
|
|||||||
game_buffconf = "game_stonebuff.json"
|
game_buffconf = "game_stonebuff.json"
|
||||||
game_eventconf = "game_stoneevent.json"
|
game_eventconf = "game_stoneevent.json"
|
||||||
game_bossconf = "game_stoneboss.json"
|
game_bossconf = "game_stoneboss.json"
|
||||||
|
game_battleconf = "game_stonebattle.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
///背包配置管理组件
|
///背包配置管理组件
|
||||||
@ -82,6 +82,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
err = this.LoadConfigure(game_eventconf, cfg.NewGameStoneEvent)
|
err = this.LoadConfigure(game_eventconf, cfg.NewGameStoneEvent)
|
||||||
err = this.LoadConfigure(game_roomconf, cfg.NewGameStoneRoom)
|
err = this.LoadConfigure(game_roomconf, cfg.NewGameStoneRoom)
|
||||||
err = this.LoadConfigure(game_bossconf, cfg.NewGameStoneBoss)
|
err = this.LoadConfigure(game_bossconf, cfg.NewGameStoneBoss)
|
||||||
|
err = this.LoadConfigure(game_battleconf, cfg.NewGameStoneBattle)
|
||||||
|
|
||||||
configure.RegisterConfigure(game_stageconf, cfg.NewGameStoneStage, this.LoadGameStoneStage)
|
configure.RegisterConfigure(game_stageconf, cfg.NewGameStoneStage, this.LoadGameStoneStage)
|
||||||
configure.RegisterConfigure(game_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff)
|
configure.RegisterConfigure(game_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff)
|
||||||
@ -146,125 +147,126 @@ func (this *configureComp) GetEventLotterConfById(id int32) (data *cfg.GameEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 实际掉落逻辑 (传入 掉落组ID vip等级 玩家等级 返回获得的道具)
|
// 实际掉落逻辑 (传入 掉落组ID vip等级 玩家等级 返回获得的道具)
|
||||||
func (this *configureComp) GetEventGroupDataByLottery(lotteryId int32) (event []int32) {
|
func (this *configureComp) GetEventGroupDataByLottery(lotterys ...int32) (event []int32) {
|
||||||
|
for _, lotteryId := range lotterys {
|
||||||
if _, ok := this._lotteryType1E[lotteryId]; !ok {
|
if _, ok := this._lotteryType1E[lotteryId]; !ok {
|
||||||
if _, ok := this._lotteryType2E[lotteryId]; !ok {
|
if _, ok := this._lotteryType2E[lotteryId]; !ok {
|
||||||
fmt.Printf("not found config lotterId:%d", lotteryId)
|
this.module.Errorf("not found config lotterId:%d", lotteryId)
|
||||||
return
|
continue
|
||||||
}
|
|
||||||
}
|
|
||||||
// 优先校验大组ID 的类型
|
|
||||||
if this.BtypeE[lotteryId] == 1 { // 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组
|
|
||||||
var (
|
|
||||||
szW []int32 // 权重数组
|
|
||||||
szID []int32 // 小组ID 数组
|
|
||||||
groupID int32
|
|
||||||
gourp map[int32]int32 // key 小组ID value 权重
|
|
||||||
)
|
|
||||||
|
|
||||||
gourp = make(map[int32]int32, 0)
|
|
||||||
// 随机小组id
|
|
||||||
for _, v := range this._lotteryType1E[lotteryId] {
|
|
||||||
if _data := this.GetEventLotterConfById(v); _data != nil {
|
|
||||||
if _, ok := gourp[_data.SubGroupId]; !ok {
|
|
||||||
gourp[_data.SubGroupId] = _data.SubGroupWt // 小组ID 权重赋值
|
|
||||||
szW = append(szW, _data.SubGroupWt)
|
|
||||||
szID = append(szID, _data.SubGroupId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 优先校验大组ID 的类型
|
||||||
|
if this.BtypeE[lotteryId] == 1 { // 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组
|
||||||
|
var (
|
||||||
|
szW []int32 // 权重数组
|
||||||
|
szID []int32 // 小组ID 数组
|
||||||
|
groupID int32
|
||||||
|
gourp map[int32]int32 // key 小组ID value 权重
|
||||||
|
)
|
||||||
|
|
||||||
groupID = szID[comm.GetRandW(szW)] // 获得小组ID
|
gourp = make(map[int32]int32, 0)
|
||||||
//fmt.Printf("大组类型为1的,获得小组ID :%d,dropID:%d", groupID, lotteryId)
|
// 随机小组id
|
||||||
key := int64(lotteryId)<<31 + int64(groupID)
|
for _, v := range this._lotteryType1E[lotteryId] {
|
||||||
// 小组ID 类型判断
|
if _data := this.GetEventLotterConfById(v); _data != nil {
|
||||||
if this.StypeE[key] == 1 { // 该小组的道具为权重掉落,必定从N个道具中随机出1个道具
|
if _, ok := gourp[_data.SubGroupId]; !ok {
|
||||||
for i := 0; i < int(this.SNumE[key]); i++ {
|
gourp[_data.SubGroupId] = _data.SubGroupWt // 小组ID 权重赋值
|
||||||
szW = make([]int32, 0)
|
szW = append(szW, _data.SubGroupWt)
|
||||||
szID = make([]int32, 0)
|
szID = append(szID, _data.SubGroupId)
|
||||||
gourp = make(map[int32]int32, 0)
|
}
|
||||||
for _, v := range this._groupType1E[key] {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
groupID = szID[comm.GetRandW(szW)] // 获得小组ID
|
||||||
|
//fmt.Printf("大组类型为1的,获得小组ID :%d,dropID:%d", groupID, lotteryId)
|
||||||
|
key := int64(lotteryId)<<31 + int64(groupID)
|
||||||
|
// 小组ID 类型判断
|
||||||
|
if this.StypeE[key] == 1 { // 该小组的道具为权重掉落,必定从N个道具中随机出1个道具
|
||||||
|
for i := 0; i < int(this.SNumE[key]); i++ {
|
||||||
|
szW = make([]int32, 0)
|
||||||
|
szID = make([]int32, 0)
|
||||||
|
gourp = make(map[int32]int32, 0)
|
||||||
|
for _, v := range this._groupType1E[key] {
|
||||||
|
if _data := this.GetEventLotterConfById(v); _data != nil { // 权重赋值
|
||||||
|
if _, ok := gourp[_data.SubGroupId]; !ok {
|
||||||
|
szW = append(szW, _data.EventWt)
|
||||||
|
szID = append(szID, _data.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index := comm.GetRandW(szW)
|
||||||
|
_data := this.GetEventLotterConfById(szID[index])
|
||||||
|
event = append(event, _data.EventID)
|
||||||
|
}
|
||||||
|
} else if this.StypeE[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比)
|
||||||
|
var wt int32
|
||||||
|
for _, v := range this._groupType2E[key] {
|
||||||
if _data := this.GetEventLotterConfById(v); _data != nil { // 权重赋值
|
if _data := this.GetEventLotterConfById(v); _data != nil { // 权重赋值
|
||||||
if _, ok := gourp[_data.SubGroupId]; !ok {
|
if _data.EventWt != 0 {
|
||||||
szW = append(szW, _data.EventWt)
|
wt = _data.EventWt
|
||||||
szID = append(szID, _data.Id)
|
}
|
||||||
|
//fmt.Printf("大组类型1小组类型2获得道具 :%v, 该道具Cid:%d", _data.Itemid, v)
|
||||||
|
if wt >= comm.GetRandNum(0, 1000) { // 命中
|
||||||
|
event = append(event, _data.EventID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index := comm.GetRandW(szW)
|
|
||||||
_data := this.GetEventLotterConfById(szID[index])
|
|
||||||
event = append(event, _data.EventID)
|
|
||||||
}
|
}
|
||||||
return
|
} else if this.BtypeE[lotteryId] == 2 { // 该大组中的小组为概率掉落,每个小组都会随机一次是否会掉落(单位为千分比)
|
||||||
} else if this.StypeE[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比)
|
// 每个小组id 都随机取一次
|
||||||
var wt int32
|
var szGroupID []int32 // 获得的权重数组
|
||||||
for _, v := range this._groupType2E[key] {
|
gourp := make([]*cfg.GameEventlotteryData, 0) // key 小组ID value 权重
|
||||||
if _data := this.GetEventLotterConfById(v); _data != nil { // 权重赋值
|
for _, v := range this._lotteryType2E[lotteryId] {
|
||||||
if _data.EventWt != 0 {
|
if _data := this.GetEventLotterConfById(v); _data != nil {
|
||||||
wt = _data.EventWt
|
gourp = append(gourp, _data)
|
||||||
}
|
|
||||||
//fmt.Printf("大组类型1小组类型2获得道具 :%v, 该道具Cid:%d", _data.Itemid, v)
|
|
||||||
if wt >= comm.GetRandNum(0, 1000) { // 命中
|
|
||||||
event = append(event, _data.EventID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
var wt int32
|
||||||
}
|
// 类型为2 可能会同时获得多个组id
|
||||||
} else if this.BtypeE[lotteryId] == 2 { // 该大组中的小组为概率掉落,每个小组都会随机一次是否会掉落(单位为千分比)
|
for _, v := range gourp {
|
||||||
// 每个小组id 都随机取一次
|
if v.SubGroupWt != 0 {
|
||||||
var szGroupID []int32 // 获得的权重数组
|
wt = v.SubGroupWt
|
||||||
gourp := make([]*cfg.GameEventlotteryData, 0) // key 小组ID value 权重
|
}
|
||||||
for _, v := range this._lotteryType2E[lotteryId] {
|
k := v.SubGroupId
|
||||||
if _data := this.GetEventLotterConfById(v); _data != nil {
|
//fmt.Printf("大组类型为2的,获得小组ID :%d,dropID:%d", k, v.Id)
|
||||||
gourp = append(gourp, _data)
|
if wt >= comm.GetRandNum(0, 1000) { // 命中
|
||||||
}
|
szGroupID = append(szGroupID, k)
|
||||||
}
|
key := int64(lotteryId)<<31 + int64(k)
|
||||||
var wt int32
|
if this.StypeE[key] == 1 { // 随机一组数据
|
||||||
// 类型为2 可能会同时获得多个组id
|
for i := 0; i < int(this.SNumE[key]); i++ {
|
||||||
for _, v := range gourp {
|
szW := make([]int32, 0)
|
||||||
if v.SubGroupWt != 0 {
|
szID := make([]int32, 0)
|
||||||
wt = v.SubGroupWt
|
gourp := make(map[int32]int32, 0)
|
||||||
}
|
for _, v := range this._groupType1E[key] {
|
||||||
k := v.SubGroupId
|
if _data := this.GetEventLotterConfById(v); _data != nil { // 权重赋值
|
||||||
//fmt.Printf("大组类型为2的,获得小组ID :%d,dropID:%d", k, v.Id)
|
if _, ok := gourp[_data.SubGroupId]; !ok {
|
||||||
if wt >= comm.GetRandNum(0, 1000) { // 命中
|
szW = append(szW, _data.EventWt)
|
||||||
szGroupID = append(szGroupID, k)
|
szID = append(szID, _data.Id)
|
||||||
key := int64(lotteryId)<<31 + int64(k)
|
}
|
||||||
if this.StypeE[key] == 1 { // 随机一组数据
|
}
|
||||||
for i := 0; i < int(this.SNumE[key]); i++ {
|
}
|
||||||
szW := make([]int32, 0)
|
index := comm.GetRandW(szW)
|
||||||
szID := make([]int32, 0)
|
_data := this.GetEventLotterConfById(szID[index])
|
||||||
gourp := make(map[int32]int32, 0)
|
event = append(event, _data.EventID)
|
||||||
for _, v := range this._groupType1E[key] {
|
}
|
||||||
|
} else if this.StypeE[key] == 2 {
|
||||||
|
for _, v := range this._groupType2E[key] {
|
||||||
|
var wt int32
|
||||||
if _data := this.GetEventLotterConfById(v); _data != nil { // 权重赋值
|
if _data := this.GetEventLotterConfById(v); _data != nil { // 权重赋值
|
||||||
if _, ok := gourp[_data.SubGroupId]; !ok {
|
if _data.EventWt != 0 {
|
||||||
szW = append(szW, _data.EventWt)
|
wt = _data.EventWt
|
||||||
szID = append(szID, _data.Id)
|
}
|
||||||
|
if wt >= comm.GetRandNum(0, 1000) { // 命中
|
||||||
|
event = append(event, _data.EventID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index := comm.GetRandW(szW)
|
|
||||||
_data := this.GetEventLotterConfById(szID[index])
|
|
||||||
event = append(event, _data.EventID)
|
|
||||||
}
|
|
||||||
} else if this.StypeE[key] == 2 {
|
|
||||||
for _, v := range this._groupType2E[key] {
|
|
||||||
var wt int32
|
|
||||||
if _data := this.GetEventLotterConfById(v); _data != nil { // 权重赋值
|
|
||||||
if _data.EventWt != 0 {
|
|
||||||
wt = _data.EventWt
|
|
||||||
}
|
|
||||||
if wt >= comm.GetRandNum(0, 1000) { // 命中
|
|
||||||
event = append(event, _data.EventID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +332,7 @@ func (this *configureComp) GetRoomGroupDataByLottery(lotteryId int32) (rooms []i
|
|||||||
|
|
||||||
if _, ok := this._lotteryType1R[lotteryId]; !ok {
|
if _, ok := this._lotteryType1R[lotteryId]; !ok {
|
||||||
if _, ok := this._lotteryType2R[lotteryId]; !ok {
|
if _, ok := this._lotteryType2R[lotteryId]; !ok {
|
||||||
fmt.Printf("not found config lotterId:%d", lotteryId)
|
this.module.Errorf("not found config lotterId:%d", lotteryId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -481,8 +483,8 @@ func (this *configureComp) GetBuffGroupDataByLottery(lotteryId int32, addType in
|
|||||||
var (
|
var (
|
||||||
num int32
|
num int32
|
||||||
szW []int32
|
szW []int32
|
||||||
curWt int32 // 是否增加权重
|
curWt int32 // 是否增加权重
|
||||||
sz []*cfg.GameBufflotteryData
|
sz []*cfg.GameBufflotteryData // 这里需要用对象池 稍后处理
|
||||||
)
|
)
|
||||||
if ownerbuff == nil {
|
if ownerbuff == nil {
|
||||||
ownerbuff = make(map[int32]struct{}, 0)
|
ownerbuff = make(map[int32]struct{}, 0)
|
||||||
@ -629,12 +631,13 @@ func (this *configureComp) CheckStage() (bossStage map[int32]*StageData) {
|
|||||||
this.GetEventGroupDataByLottery(roomconf.BossEvent)
|
this.GetEventGroupDataByLottery(roomconf.BossEvent)
|
||||||
// 生成 我方buff
|
// 生成 我方buff
|
||||||
if bossConf := this.GetBossConfById(roomconf.BossEvent); bossConf != nil {
|
if bossConf := this.GetBossConfById(roomconf.BossEvent); bossConf != nil {
|
||||||
stageData.maineBuff = this.GetBuffGroupDataByLottery(bossConf.FriendlyBuffGroup, 0, nil)
|
stageData.MaineBuff = this.GetBuffGroupDataByLottery(bossConf.FriendlyBuffGroup, 0, nil)
|
||||||
stageData.enemyBuff = this.GetBuffGroupDataByLottery(bossConf.EnemyBuffGroup, 0, nil)
|
stageData.EnemyBuff = this.GetBuffGroupDataByLottery(bossConf.EnemyBuffGroup, 0, nil)
|
||||||
}
|
}
|
||||||
stageData.rtime = configure.Now().Unix()
|
stageData.Roomid = rooms[0]
|
||||||
|
stageData.Rtime = configure.Now().Unix()
|
||||||
}
|
}
|
||||||
bossStage[rooms[0]] = stageData
|
bossStage[k] = stageData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -649,3 +652,23 @@ func (this *configureComp) GetBossConfById(id int32) (data *cfg.GameStoneBossDat
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 通过关卡id 找层数
|
||||||
|
func (this *configureComp) GetFloorConfByStageId(stageId int32) int32 {
|
||||||
|
return this.szStage[stageId]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *configureComp) GetBattleConfById(id int32) (data *cfg.GameStoneBattleData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_battleconf); err == nil {
|
||||||
|
if configure, ok := v.(*cfg.GameStoneBattle); ok {
|
||||||
|
if data = configure.Get(id); data != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = comm.NewNotFoundConfErr(moduleName, game_battleconf, id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -19,11 +19,14 @@ const (
|
|||||||
StoneBossKey = "StoneBossKey"
|
StoneBossKey = "StoneBossKey"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type DBStoneBoss struct {
|
||||||
|
BossStage map[int32]*StageData
|
||||||
|
}
|
||||||
type StageData struct {
|
type StageData struct {
|
||||||
maineBuff []int32 // 我方buff
|
MaineBuff []int32 // 我方buff
|
||||||
enemyBuff []int32 // 敌方buff
|
EnemyBuff []int32 // 敌方buff
|
||||||
roomid int32 // 传送门id
|
Roomid int32 // 传送门id
|
||||||
rtime int64 // 刷新时间
|
Rtime int64 // 刷新时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// 石阵秘境
|
// 石阵秘境
|
||||||
@ -80,11 +83,28 @@ func (this *MStonehenge) ChangeStonehengeData(uid string, update map[string]inte
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *MStonehenge) loadStoneBoos() (err error) {
|
func (this *MStonehenge) loadStoneBoos() (err error) {
|
||||||
|
var (
|
||||||
this.module.ModuleTools.GetGlobalData(StoneBossKey, this.bossStage)
|
bNewData bool
|
||||||
if len(this.bossStage) == 0 {
|
)
|
||||||
// 生成数据
|
s := &DBStoneBoss{}
|
||||||
|
this.module.ModuleTools.GetGlobalData(StoneBossKey, s)
|
||||||
|
if len(s.BossStage) == 0 {
|
||||||
|
bNewData = true
|
||||||
|
} else { // 校验时间
|
||||||
|
for _, v := range s.BossStage {
|
||||||
|
if utils.WeekIntervalTime(0) != v.Rtime {
|
||||||
|
bNewData = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if bNewData {
|
||||||
|
this.lock.Lock()
|
||||||
this.bossStage = this.module.configure.CheckStage()
|
this.bossStage = this.module.configure.CheckStage()
|
||||||
|
this.lock.Unlock()
|
||||||
|
this.module.ModuleTools.UpdateGlobalData(StoneBossKey, map[string]interface{}{
|
||||||
|
"BossStage": this.bossStage,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ type Stonehenge struct {
|
|||||||
|
|
||||||
//模块名
|
//模块名
|
||||||
func (this *Stonehenge) GetType() core.M_Modules {
|
func (this *Stonehenge) GetType() core.M_Modules {
|
||||||
return comm.ModuleAcademy
|
return comm.ModuleStone
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块初始化接口 注册用户创建角色事件
|
//模块初始化接口 注册用户创建角色事件
|
||||||
|
Loading…
Reference in New Issue
Block a user