package uigame import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) //参数校验 func (this *apiComp) PuzzleGridCheck(session comm.IUserSession, req *pb.UiGamePuzzleGridReq) (errdata *pb.ErrorData) { if req.Hdid == "" { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } return } return } // 点击某个格子进行拼图 func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleGridReq) (errdata *pb.ErrorData) { if errdata = this.PuzzleGridCheck(session, req); errdata != nil { return // 参数校验失败直接返回 } var ( atno []*pb.UserAtno ) list, _ := this.module.modelPuzzle.getPuzzleList(session.GetUserId(), req.Hdid) if _, ok := list.Puzzle[req.Grid]; ok { // 重复拼图 return } // 校验消耗 if conf, err := this.module.configure.GetPuzzleConsumConf(); err == nil { if conf.Cost.N > 0 { if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{conf.Cost}, true); errdata != nil { return } } if conf.Itemget.N > 0 { if errdata, atno = this.module.DispenseAtno(session, []*cfg.Gameatn{conf.Itemget}, true); errdata != nil { return } } } list.Puzzle[req.Grid] = 1 update := make(map[string]interface{}, 0) update["puzzle"] = list.Puzzle this.module.modelPuzzle.modifyPuzzleListByObjId(session.GetUserId(), update) // 修改进度 session.SendMsg(string(this.module.GetType()), "puzzlegrid", &pb.UiGamePuzzleGridResp{ Data: list, Atno: atno, }) return }