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 }