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" //每日任务
|
||||
ModuleQuestionnaire core.M_Modules = "questionnaire" //问卷调查
|
||||
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
|
||||
szBuff []int32
|
||||
err error
|
||||
szEvent []int32
|
||||
)
|
||||
update = make(map[string]interface{})
|
||||
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 {
|
||||
return
|
||||
}
|
||||
if roomConf.EventrewardGroup != 0 { // 参数校验
|
||||
szBuff = this.module.configure.GetEventGroupDataByLottery(roomConf.EventrewardGroup)
|
||||
if roomConf.EventrewardGroup != 0 { // 垃圾事件组
|
||||
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 {
|
||||
stone.Rooms.Eventid[v] = true
|
||||
}
|
||||
}
|
||||
|
||||
update["rooms"] = stone.Rooms
|
||||
stone.CurRoomIndes = 1 // 第一次进房间 默认第一关
|
||||
update["curRoomIndes"] = stone.CurRoomIndes
|
||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||
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{}
|
||||
update["rooms"] = stone.Rooms
|
||||
stone.Webuff = make([]int32, 0)
|
||||
update["envbuff"] = stone.Webuff
|
||||
update["webuff"] = stone.Webuff
|
||||
stone.Enemybuff = make([]int32, 0)
|
||||
update["enemybuff"] = stone.Enemybuff
|
||||
stone.Userbuff = make(map[int32]int32)
|
||||
update["userbuff"] = stone.Userbuff
|
||||
stone.Hero = make([]*pb.BattleRole, 0)
|
||||
update["hero"] = stone.Hero
|
||||
|
||||
stone.Addweight = make(map[int32]int32, 0)
|
||||
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) {
|
||||
var (
|
||||
stone *pb.DBStonehenge
|
||||
rooms []int32
|
||||
)
|
||||
if errdata = this.GetListCheck(session, req); errdata != nil {
|
||||
return
|
||||
@ -31,20 +32,27 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.StonehengeGetLis
|
||||
stone.Rooms = &pb.RoomData{}
|
||||
update["rooms"] = stone.Rooms
|
||||
stone.Webuff = make([]int32, 0)
|
||||
update["envbuff"] = stone.Webuff
|
||||
update["webuff"] = stone.Webuff
|
||||
stone.Enemybuff = make([]int32, 0)
|
||||
update["enemybuff"] = stone.Enemybuff
|
||||
stone.Userbuff = make(map[int32]int32)
|
||||
update["userbuff"] = stone.Userbuff
|
||||
stone.Hero = make([]*pb.BattleRole, 0)
|
||||
update["hero"] = stone.Hero
|
||||
|
||||
stone.Addweight = make(map[int32]int32, 0)
|
||||
update["addweight"] = stone.Addweight
|
||||
|
||||
stone.Etime = utils.WeekIntervalTime(0)
|
||||
update["etime"] = stone.Etime
|
||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.StonehengeGetListResp{Data: stone})
|
||||
s := &DBStoneBoss{}
|
||||
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
|
||||
}
|
||||
|
@ -52,12 +52,22 @@ func (this *apiComp) GotoRoom(session comm.IUserSession, req *pb.StonehengeGotoR
|
||||
return
|
||||
}
|
||||
stone.CurRoomIndes += 1
|
||||
|
||||
update["curRoomIndes"] = stone.CurRoomIndes
|
||||
stone.Rooms = &pb.RoomData{
|
||||
Eventid: map[int32]bool{},
|
||||
Roomid: req.Portal,
|
||||
Index: stone.CurRoomIndes,
|
||||
}
|
||||
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
|
||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||
session.SendMsg(string(this.module.GetType()), "gotoroom", &pb.StonehengeGotoRoomResp{})
|
||||
|
@ -1,7 +1,6 @@
|
||||
package stonehenge
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
@ -20,6 +19,7 @@ const (
|
||||
game_buffconf = "game_stonebuff.json"
|
||||
game_eventconf = "game_stoneevent.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_roomconf, cfg.NewGameStoneRoom)
|
||||
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_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff)
|
||||
@ -146,12 +147,12 @@ func (this *configureComp) GetEventLotterConfById(id int32) (data *cfg.GameEvent
|
||||
}
|
||||
|
||||
// 实际掉落逻辑 (传入 掉落组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._lotteryType2E[lotteryId]; !ok {
|
||||
fmt.Printf("not found config lotterId:%d", lotteryId)
|
||||
return
|
||||
this.module.Errorf("not found config lotterId:%d", lotteryId)
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 优先校验大组ID 的类型
|
||||
@ -196,7 +197,6 @@ func (this *configureComp) GetEventGroupDataByLottery(lotteryId int32) (event []
|
||||
_data := this.GetEventLotterConfById(szID[index])
|
||||
event = append(event, _data.EventID)
|
||||
}
|
||||
return
|
||||
} else if this.StypeE[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比)
|
||||
var wt int32
|
||||
for _, v := range this._groupType2E[key] {
|
||||
@ -210,7 +210,7 @@ func (this *configureComp) GetEventGroupDataByLottery(lotteryId int32) (event []
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
} else if this.BtypeE[lotteryId] == 2 { // 该大组中的小组为概率掉落,每个小组都会随机一次是否会掉落(单位为千分比)
|
||||
// 每个小组id 都随机取一次
|
||||
@ -265,6 +265,8 @@ func (this *configureComp) GetEventGroupDataByLottery(lotteryId int32) (event []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -330,7 +332,7 @@ func (this *configureComp) GetRoomGroupDataByLottery(lotteryId int32) (rooms []i
|
||||
|
||||
if _, ok := this._lotteryType1R[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
|
||||
}
|
||||
}
|
||||
@ -482,7 +484,7 @@ func (this *configureComp) GetBuffGroupDataByLottery(lotteryId int32, addType in
|
||||
num int32
|
||||
szW []int32
|
||||
curWt int32 // 是否增加权重
|
||||
sz []*cfg.GameBufflotteryData
|
||||
sz []*cfg.GameBufflotteryData // 这里需要用对象池 稍后处理
|
||||
)
|
||||
if ownerbuff == nil {
|
||||
ownerbuff = make(map[int32]struct{}, 0)
|
||||
@ -629,12 +631,13 @@ func (this *configureComp) CheckStage() (bossStage map[int32]*StageData) {
|
||||
this.GetEventGroupDataByLottery(roomconf.BossEvent)
|
||||
// 生成 我方buff
|
||||
if bossConf := this.GetBossConfById(roomconf.BossEvent); bossConf != nil {
|
||||
stageData.maineBuff = this.GetBuffGroupDataByLottery(bossConf.FriendlyBuffGroup, 0, nil)
|
||||
stageData.enemyBuff = this.GetBuffGroupDataByLottery(bossConf.EnemyBuffGroup, 0, nil)
|
||||
stageData.MaineBuff = this.GetBuffGroupDataByLottery(bossConf.FriendlyBuffGroup, 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
|
||||
}
|
||||
|
||||
// 通过关卡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"
|
||||
)
|
||||
|
||||
type DBStoneBoss struct {
|
||||
BossStage map[int32]*StageData
|
||||
}
|
||||
type StageData struct {
|
||||
maineBuff []int32 // 我方buff
|
||||
enemyBuff []int32 // 敌方buff
|
||||
roomid int32 // 传送门id
|
||||
rtime int64 // 刷新时间
|
||||
MaineBuff []int32 // 我方buff
|
||||
EnemyBuff []int32 // 敌方buff
|
||||
Roomid int32 // 传送门id
|
||||
Rtime int64 // 刷新时间
|
||||
}
|
||||
|
||||
// 石阵秘境
|
||||
@ -80,11 +83,28 @@ func (this *MStonehenge) ChangeStonehengeData(uid string, update map[string]inte
|
||||
}
|
||||
|
||||
func (this *MStonehenge) loadStoneBoos() (err error) {
|
||||
|
||||
this.module.ModuleTools.GetGlobalData(StoneBossKey, this.bossStage)
|
||||
if len(this.bossStage) == 0 {
|
||||
// 生成数据
|
||||
var (
|
||||
bNewData bool
|
||||
)
|
||||
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.lock.Unlock()
|
||||
this.module.ModuleTools.UpdateGlobalData(StoneBossKey, map[string]interface{}{
|
||||
"BossStage": this.bossStage,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ type Stonehenge struct {
|
||||
|
||||
//模块名
|
||||
func (this *Stonehenge) GetType() core.M_Modules {
|
||||
return comm.ModuleAcademy
|
||||
return comm.ModuleStone
|
||||
}
|
||||
|
||||
//模块初始化接口 注册用户创建角色事件
|
||||
|
Loading…
Reference in New Issue
Block a user