package uigame import ( "go_dreamfactory/comm" "go_dreamfactory/pb" ) //参数校验 func (this *apiComp) LatticeRewardCheck(session comm.IUserSession, req *pb.UiGameLatticeRewardReq) (errdata *pb.ErrorData) { if req.Hdid == "" || req.Id == 0 { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } } return } // 点击某个格子进行拼图 func (this *apiComp) LatticeReward(session comm.IUserSession, req *pb.UiGameLatticeRewardReq) (errdata *pb.ErrorData) { if errdata = this.LatticeRewardCheck(session, req); errdata != nil { return // 参数校验失败直接返回 } var ( atno []*pb.UserAtno ) list, _ := this.module.modelLattice.getLatticeList(session.GetUserId(), req.Hdid) conf, err := this.module.configure.GetLatticeConf(req.Id) if err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } if len(conf.Openward) == 0 { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } return } if _, ok := list.Gotarr[req.Id]; ok { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ActivityRepatReward, Title: pb.ErrorCode_ActivityRepatReward.ToString(), } return } if errdata, atno = this.module.DispenseAtno(session, conf.Openward, true); errdata != nil { return } // 记录数据 list.Gotarr[req.Id] = 1 update := make(map[string]interface{}, 0) update["gotarr"] = list.Gotarr this.module.modelLattice.modifyLatticeListByObjId(session.GetUserId(), update) // 修改进度 session.SendMsg(string(this.module.GetType()), "latticereward", &pb.UiGameLatticeRewardResp{ Data: list, Atno: atno, }) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "UiGameLatticeRewardReq", atno) }) return }