go_dreamfactory/modules/practice/api_unLock.go
2023-12-13 17:15:20 +08:00

89 lines
2.2 KiB
Go

package practice
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
)
// 参数校验
func (this *apiComp) UnLockCheck(session comm.IUserSession, req *pb.PracticeUnLockReq) (errdata *pb.ErrorData) {
return
}
// /练功请求 解锁木桩
func (this *apiComp) UnLock(session comm.IUserSession, req *pb.PracticeUnLockReq) (errdata *pb.ErrorData) {
var (
err error
room *pb.DBPracticeRoom
pillar *pb.DBPracticePillar
filed string
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
res []*cfg.Gameatn
)
if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
switch req.Index {
case 1:
pillar = room.Pillar1
filed = "pillar1"
break
case 2:
pillar = room.Pillar2
filed = "pillar2"
break
case 3:
pillar = room.Pillar3
filed = "pillar3"
break
case 4:
pillar = room.Pillarf
filed = "pillarf"
break
}
if pillar.Isunlock != 1 {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
return
}
pillar.Isunlock = 2
if room.Pillarf.Isunlock == 0 {
room.Pillarf.Isunlock = 2
}
if pillarconfigure, err := this.module.configure.getGamePandamasMz(req.Index); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
} else {
res = append(res, pillarconfigure.PhotoGuideUnlocking...)
if errdata = this.module.DispenseRes(session, res, true); errdata != nil {
return
}
}
this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{
filed: pillar,
"pillarf": room.Pillarf,
})
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype152, 1))
session.SendMsg(string(this.module.GetType()), "unlock", &pb.PracticeUnLockResp{Info: room})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "PracticeUnLockReq", res)
})
return
}