update
This commit is contained in:
parent
7afd084cde
commit
c3e87890bc
@ -95,7 +95,7 @@ const (
|
||||
ModuleDailytask core.M_Modules = "dailytask" //每日任务
|
||||
ModuleQuestionnaire core.M_Modules = "questionnaire" //问卷调查
|
||||
ModuleMainline core.M_Modules = "mainline" //主线模块
|
||||
ModuleStone core.M_Modules = "stonetenge"
|
||||
ModuleStone core.M_Modules = "stonehenge"
|
||||
)
|
||||
|
||||
// 数据表名定义处
|
||||
|
@ -1,60 +0,0 @@
|
||||
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
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
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.StonehengeBattleReq) (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
|
||||
}
|
Loading…
Reference in New Issue
Block a user