package stonehenge import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) //参数校验 func (this *apiComp) FinishCheck(session comm.IUserSession, req *pb.StonehengeFinishReq) (errdata *pb.ErrorData) { return } // 结算房间 func (this *apiComp) Finish(session comm.IUserSession, req *pb.StonehengeFinishReq) (errdata *pb.ErrorData) { var ( stone *pb.DBStonehenge update map[string]interface{} err error curintegral int32 atno []*pb.UserAtno reward []*pb.UserAtno ) update = make(map[string]interface{}) if errdata = this.FinishCheck(session, req); errdata != nil { return } if stone, err = this.module.modelStonehenge.GetStonehengeData(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.String(), Message: err.Error(), } return } // 校验是否是通关 if stone.Rooms.Complete { if conf := this.module.configure.GetStageConfByStageid(stone.StageID, stone.CurRoomIndes+1); conf == nil { stone.Reward[stone.StageID] = true update["reward"] = stone.Reward // 设置关卡通关状态 if conf := this.module.configure.GetStageConfByStageid(stone.StageID, 1); conf != nil { if len(conf.FirstReward) > 0 { // 完成关卡 发放当前关奖励 if errdata, reward = this.module.DispenseAtno(session, conf.FirstReward, true); errdata != nil { return } atno = append(atno, reward...) } } } if conf := this.module.configure.GetStageConfByStageid(stone.StageID, stone.CurRoomIndes); conf != nil { stone.Integral += conf.WeeklyPoint // 发放积分 和奖励 update["integral"] = stone.Integral curintegral = conf.WeeklyPoint // 再发天赋奖励 if errdata, atno = this.module.DispenseAtno(session, []*cfg.Gameatn{conf.TalentItem}, true); errdata != nil { return } } } else { // 没有通关也不要紧 发前面关卡奖励 if stone.CurRoomIndes > 1 { if conf := this.module.configure.GetStageConfByStageid(stone.StageID, 1); conf != nil { if len(conf.FirstReward) > 0 { // 完成关卡 发放当前关奖励 if errdata, reward = this.module.DispenseAtno(session, conf.FirstReward, true); errdata != nil { return } atno = append(atno, reward...) } } if conf := this.module.configure.GetStageConfByStageid(stone.StageID, stone.CurRoomIndes-1); conf != nil { stone.Integral += conf.WeeklyPoint // 发放积分 和奖励 update["integral"] = stone.Integral curintegral = conf.WeeklyPoint // 再发天赋奖励 if errdata, atno = this.module.DispenseAtno(session, []*cfg.Gameatn{conf.TalentItem}, true); errdata != nil { return } } } } stone.StageID = 0 update["stageID"] = stone.StageID stone.CurRoomIndes = 0 update["curRoomIndes"] = stone.CurRoomIndes stone.Rooms = nil update["rooms"] = stone.Rooms stone.Webuff = make([]int32, 0) 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(map[string]*pb.BattleRole) update["hero"] = stone.Hero stone.Addweight = make(map[int32]int32, 0) update["addweight"] = stone.Addweight // 清除指定类型道具 item,10000036 该货币在关卡结算时,清空 this.module.ModuleItems.CleanItemById(session, "10000036") // 策划强烈要求这样写 this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update) session.SendMsg(string(this.module.GetType()), "finish", &pb.StonehengeFinishResp{ Data: stone, Curintegral: curintegral, Reward: atno, }) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "StonehengeFinishReq", atno) }) return }