46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package catchbugs
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
func (this *apiComp) PassLevelCheck(session comm.IUserSession, req *pb.CatchbugsPassLevelReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) PassLevel(session comm.IUserSession, req *pb.CatchbugsPassLevelReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
conf *cfg.GameCatchbugStageData
|
|
info *pb.DBCatchBugs
|
|
err error
|
|
)
|
|
if errdata = this.PassLevelCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getGameCatchbugStage(req.Level); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.model.getModel(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
info.Integral += conf.Points
|
|
info.Level[req.Level] = true
|
|
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"integral": info.Integral,
|
|
"level": info.Level,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "award", &pb.CatchbugsPassLevelResp{Level: req.Level, Integral: info.Integral})
|
|
return
|
|
}
|