113 lines
3.4 KiB
Go
113 lines
3.4 KiB
Go
package stonehenge
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) EnterLevelCheck(session comm.IUserSession, req *pb.StonehengeEnterLevelReq) (errdata *pb.ErrorData) {
|
|
if req.Stageid == 0 || len(req.Hid) == 0 || req.BuffType == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//进入关卡 选择英雄和buff 一起处理
|
|
func (this *apiComp) EnterLevel(session comm.IUserSession, req *pb.StonehengeEnterLevelReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
stone *pb.DBStonehenge
|
|
update map[string]interface{}
|
|
heros []*pb.DBHero
|
|
portal int32 // 生成传送门 构造房间数据
|
|
confStage *cfg.GameStroneStageData
|
|
roomlotteryConf *cfg.GameRoomlotteryData
|
|
roomConf *cfg.GameStroneRoomData
|
|
szBuff []int32
|
|
err error
|
|
)
|
|
update = make(map[string]interface{})
|
|
if errdata = this.EnterLevelCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
confStage = this.module.configure.GetStageConfByStageid(req.Stageid, 1)
|
|
if confStage == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
}
|
|
return
|
|
}
|
|
portal = confStage.RoomGroup
|
|
this.module.Debugf("%v", confStage)
|
|
stone = this.module.modelStonehenge.GetStonehengeData(session.GetUserId())
|
|
|
|
if len(stone.Hero) != 0 || len(stone.Addweight) != 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_StonehengeEnterRoomFailed,
|
|
Title: pb.ErrorCode_StonehengeEnterRoomFailed.ToString(),
|
|
}
|
|
return
|
|
}
|
|
// 查库
|
|
for _, hid := range req.Hid {
|
|
if hero, err := this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), hid); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_HeroNoExist,
|
|
Message: pb.ErrorCode_HeroNoExist.ToString(),
|
|
}
|
|
return
|
|
} else {
|
|
heros = append(heros, hero)
|
|
}
|
|
}
|
|
if stone.Hero, errdata = this.module.battle.CreateRolesByHeros(heros); errdata != nil {
|
|
return
|
|
}
|
|
update["hero"] = stone.Hero
|
|
stone.Addweight[req.BuffType] = 1
|
|
update["addweight"] = stone.Addweight
|
|
// 生成传送门
|
|
if roomlotteryConf = this.module.configure.GetRoomLotterConfById(portal); roomlotteryConf != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: fmt.Sprintf("GetRoomLotterConfById :%d", portal),
|
|
}
|
|
return
|
|
}
|
|
|
|
stone.Rooms = &pb.RoomData{
|
|
Eventid: map[int32]bool{},
|
|
Portal: this.module.configure.GetRoomGroupDataByLottery(confStage.PortalGroup),
|
|
Selectbuff: []int32{},
|
|
Complete: false,
|
|
Index: 1,
|
|
Roomid: confStage.RoomGroup, // 第一个房间的房间id读配置
|
|
}
|
|
|
|
if roomConf, err = this.module.configure.GetStoneRoomDataById(portal); err != nil {
|
|
return
|
|
}
|
|
if roomConf.EventrewardGroup != 0 { // 参数校验
|
|
szBuff = this.module.configure.GetEventGroupDataByLottery(roomConf.EventrewardGroup)
|
|
for _, v := range szBuff {
|
|
stone.Rooms.Eventid[v] = true
|
|
}
|
|
}
|
|
|
|
update["rooms"] = stone.Rooms
|
|
update["curRoomIndes"] = stone.CurRoomIndes
|
|
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
|
session.SendMsg(string(this.module.GetType()), "enterlevel", &pb.StonehengeEnterLevelResp{
|
|
Hero: stone.Hero,
|
|
Room: stone.Rooms,
|
|
})
|
|
return
|
|
}
|