更改module命名
This commit is contained in:
parent
392c7d3ecf
commit
b3e16d641e
@ -14,12 +14,12 @@ const (
|
|||||||
type apiComp struct {
|
type apiComp struct {
|
||||||
modules.MCompGate
|
modules.MCompGate
|
||||||
service core.IService
|
service core.IService
|
||||||
moduleLinestory *ModuleLinestory
|
module *ModuleLinestory
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MCompGate.Init(service, module, comp, options)
|
this.MCompGate.Init(service, module, comp, options)
|
||||||
this.moduleLinestory = module.(*ModuleLinestory)
|
this.module = module.(*ModuleLinestory)
|
||||||
this.service = service
|
this.service = service
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@ func (this *apiComp) ChapterCheck(session comm.IUserSession, req *pb.LinestoryCh
|
|||||||
|
|
||||||
func (this *apiComp) Chapter(session comm.IUserSession, req *pb.LinestoryChapterReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
func (this *apiComp) Chapter(session comm.IUserSession, req *pb.LinestoryChapterReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
taskMap := this.moduleLinestory.modelLinestory.getChapters(uid)
|
taskMap := this.module.modelLinestory.getChapters(uid)
|
||||||
rsp := &pb.LinestoryChapterResp{
|
rsp := &pb.LinestoryChapterResp{
|
||||||
TaskChapter: taskMap,
|
TaskChapter: taskMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := session.SendMsg(string(this.moduleLinestory.GetType()), LinestorySubTypeChapter, rsp); err != nil {
|
if err := session.SendMsg(string(this.module.GetType()), LinestorySubTypeChapter, rsp); err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
// 支线剧情-我的主线任务
|
// 支线剧情-我的主线任务
|
||||||
func (this *apiComp) MaintaskCheck(session comm.IUserSession, req *pb.LinestoryMaintaskReq) (code pb.ErrorCode) {
|
func (this *apiComp) MaintaskCheck(session comm.IUserSession, req *pb.LinestoryMaintaskReq) (code pb.ErrorCode) {
|
||||||
if req.ChapterId == 0 {
|
if req.ChapterId == 0 {
|
||||||
this.moduleLinestory.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
|
this.module.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
|
||||||
code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -22,13 +22,13 @@ func (this *apiComp) Maintask(session comm.IUserSession, req *pb.LinestoryMainta
|
|||||||
|
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
// 我的主线任务
|
// 我的主线任务
|
||||||
list := this.moduleLinestory.modelLinestory.getMaintasks(uid, req.ChapterId)
|
list := this.module.modelLinestory.getMaintasks(uid, req.ChapterId)
|
||||||
|
|
||||||
rsp := &pb.LinestoryMaintaskResp{
|
rsp := &pb.LinestoryMaintaskResp{
|
||||||
List: list,
|
List: list,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := session.SendMsg(string(this.moduleLinestory.GetType()), LinestorySubTypeMaintask, rsp); err != nil {
|
if err := session.SendMsg(string(this.module.GetType()), LinestorySubTypeMaintask, rsp); err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
// 章节奖励领取
|
// 章节奖励领取
|
||||||
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.LinestoryReceiveReq) (code pb.ErrorCode) {
|
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.LinestoryReceiveReq) (code pb.ErrorCode) {
|
||||||
if req.ChapterId == 0 {
|
if req.ChapterId == 0 {
|
||||||
this.moduleLinestory.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
|
this.module.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
|
||||||
code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -22,27 +22,27 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
conf := this.moduleLinestory.configure.getChapterCfgById(req.ChapterId)
|
conf := this.module.configure.getChapterCfgById(req.ChapterId)
|
||||||
if conf == nil {
|
if conf == nil {
|
||||||
this.moduleLinestory.Error("配置未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId})
|
this.module.Error("配置未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId})
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := this.moduleLinestory.modelLinestory.receive(uid, req.ChapterId); err != nil {
|
if err := this.module.modelLinestory.receive(uid, req.ChapterId); err != nil {
|
||||||
var customErr = new(comm.CustomError)
|
var customErr = new(comm.CustomError)
|
||||||
if errors.As(err, &customErr) {
|
if errors.As(err, &customErr) {
|
||||||
code = customErr.Code
|
code = customErr.Code
|
||||||
} else {
|
} else {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
}
|
}
|
||||||
this.moduleLinestory.Error("章节奖励领取失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}, log.Field{Key: "code", Value: code})
|
this.module.Error("章节奖励领取失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}, log.Field{Key: "code", Value: code})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//发奖
|
//发奖
|
||||||
if code = this.moduleLinestory.DispenseRes(session, conf.Reward, true); code != pb.ErrorCode_Success {
|
if code = this.module.DispenseRes(session, conf.Reward, true); code != pb.ErrorCode_Success {
|
||||||
this.moduleLinestory.Error("奖励发放失败",
|
this.module.Error("奖励发放失败",
|
||||||
log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}, log.Field{Key: "reward", Value: conf.Reward},
|
log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}, log.Field{Key: "reward", Value: conf.Reward},
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -52,7 +52,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive
|
|||||||
ChapterId: req.ChapterId,
|
ChapterId: req.ChapterId,
|
||||||
UserAssets: utils.ConvertReward(conf.Reward...),
|
UserAssets: utils.ConvertReward(conf.Reward...),
|
||||||
}
|
}
|
||||||
if err := session.SendMsg(string(this.moduleLinestory.GetType()), LinestorySubTypeReceive, rsp); err != nil {
|
if err := session.SendMsg(string(this.module.GetType()), LinestorySubTypeReceive, rsp); err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -85,30 +85,11 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq)
|
|||||||
a.module.modelWorldtask.taskFinish(session, req.GroupId, req.TaskId, myWorldtask, curTaskConf)
|
a.module.modelWorldtask.taskFinish(session, req.GroupId, req.TaskId, myWorldtask, curTaskConf)
|
||||||
a.module.modelWorldtask.taskFinishPush(session, req.GroupId, myWorldtask, curTaskConf)
|
a.module.modelWorldtask.taskFinishPush(session, req.GroupId, myWorldtask, curTaskConf)
|
||||||
} else {
|
} else {
|
||||||
// 检查任务条件是否已完成
|
// 已完成的任务条件
|
||||||
rsp.CondiIds = a.checkCurrentCompleteCond(uid, curTaskConf.Completetask, myWorldtask)
|
rsp.CondiIds = a.module.ModuleBuried.CheckCondition(uid, curTaskConf.Completetask...)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.sendMsg(session, WorldtaskSubtypeAccept, rsp)
|
a.sendMsg(session, WorldtaskSubtypeAccept, rsp)
|
||||||
return
|
a.module.ModuleBuried.ActiveCondition(uid, curTaskConf.Completetask...)
|
||||||
}
|
|
||||||
|
|
||||||
// 检查当前任务的完成条件
|
|
||||||
func (this *apiComp) checkCurrentCompleteCond(uid string, completeCondIds []int32, userTask *pb.DBWorldtask) (condIds []int32) {
|
|
||||||
|
|
||||||
for _, condId := range completeCondIds {
|
|
||||||
if condId == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if m, err := this.module.service.GetModule(comm.ModuleRtask); err == nil {
|
|
||||||
iwt, ok := m.(comm.IRtask)
|
|
||||||
if ok {
|
|
||||||
if mc := iwt.CheckCondi(uid, condId); mc == pb.ErrorCode_Success {
|
|
||||||
condIds = append(condIds, condId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/base"
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/event"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
Loading…
Reference in New Issue
Block a user