支线剧情日志

This commit is contained in:
wh_zcy 2022-11-17 14:38:51 +08:00
parent af3ce8f4e8
commit 77e57cbd47
5 changed files with 23 additions and 9 deletions

View File

@ -32,6 +32,7 @@ func (this *ModelLinestory) getLinestory(uid string) *pb.DBLinestory {
if err := this.Get(uid, ls); err != nil { if err := this.Get(uid, ls); err != nil {
if err == mongo.ErrNoDocuments { if err == mongo.ErrNoDocuments {
ls.Id = primitive.NewObjectID().Hex() ls.Id = primitive.NewObjectID().Hex()
if err := this.Add(uid, ls); err != nil { if err := this.Add(uid, ls); err != nil {
log.Errorf("save linestory err:%v", err) log.Errorf("save linestory err:%v", err)
return ls return ls

View File

@ -6,6 +6,7 @@ package linestory
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
@ -57,7 +58,7 @@ func (this *ModuleLinestory) Start() (err error) {
// 世界任务完成通知 // 世界任务完成通知
func (this *ModuleLinestory) TaskFinishNotify(uid string, taskId, groupId int32) error { func (this *ModuleLinestory) TaskFinishNotify(uid string, taskId, groupId int32) error {
ls := this.modelLinestory.getLinestory(uid) ls := this.modelLinestory.getLinestory(uid)
log.Debug("支线剧情任务", log.Fields{"uid": uid, "groupId": groupId, "taskId": taskId})
var isUpdate bool var isUpdate bool
if chapter, ok := ls.TaskChapter[groupId]; ok { if chapter, ok := ls.TaskChapter[groupId]; ok {
if _, ok := utils.Findx(chapter.TaskIds, taskId); !ok { if _, ok := utils.Findx(chapter.TaskIds, taskId); !ok {
@ -73,16 +74,28 @@ func (this *ModuleLinestory) TaskFinishNotify(uid string, taskId, groupId int32)
// 重置任务ID // 重置任务ID
if conf, ok := this.confMaintask.GetDataMap()[taskId]; ok { if conf, ok := this.confMaintask.GetDataMap()[taskId]; ok {
if conf.Group == groupId { if conf.Group == groupId {
var newTaskList []int32 if len(conf.Resetto) > 0 {
for _, v := range conf.Resetto { var newTaskList []int32
newTaskList = utils.Deletex(chapter.TaskIds, v) for _, v := range conf.Resetto {
newTaskList = utils.Deletex(chapter.TaskIds, v)
}
chapter.TaskIds = newTaskList
} }
chapter.TaskIds = newTaskList
} }
} }
isUpdate = true isUpdate = true
} }
} else { } else {
// 校验groupId 或taskId是否合法
if _, ok := this.confTimeline.GetDataMap()[groupId]; !ok {
this.Debug("非支线剧情任务", log.Fields{"uid": uid, "groupId": groupId, "taskId": taskId})
return comm.NewCustomError(pb.ErrorCode_ReqParameterError)
}
if _, ok := this.confMaintask.GetDataMap()[taskId]; !ok {
this.Debug("非支线剧情任务", log.Fields{"uid": uid, "groupId": groupId, "taskId": taskId})
return comm.NewCustomError(pb.ErrorCode_ReqParameterError)
}
tg := &pb.TaskChapter{} tg := &pb.TaskChapter{}
// 设置完成的任务 // 设置完成的任务
tg.TaskIds = append(tg.TaskIds, taskId) tg.TaskIds = append(tg.TaskIds, taskId)

View File

@ -11,7 +11,7 @@ import (
// 战斗结束的请求 // 战斗结束的请求
func (this *apiComp) BattlefinishCheck(session comm.IUserSession, req *pb.WorldtaskBattleFinishReq) (code pb.ErrorCode) { func (this *apiComp) BattlefinishCheck(session comm.IUserSession, req *pb.WorldtaskBattleFinishReq) (code pb.ErrorCode) {
if req.BattleConfId == 0 || req.TaskId == 0 || req.Report == nil { if req.BattleConfId == 0 || req.TaskId == 0 || req.Report == nil {
this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) this.module.Error("世界任务战斗结束参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return

View File

@ -11,7 +11,7 @@ import (
// 战斗开始 // 战斗开始
func (this *apiComp) BattlestartCheck(session comm.IUserSession, req *pb.WorldtaskBattleStartReq) (code pb.ErrorCode) { func (this *apiComp) BattlestartCheck(session comm.IUserSession, req *pb.WorldtaskBattleStartReq) (code pb.ErrorCode) {
if req.BattleConfId == 0 || req.Battle != nil { if req.BattleConfId == 0 || req.Battle != nil {
this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) this.module.Error("世界任务战斗开始参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return

View File

@ -8,11 +8,11 @@ import (
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
// 任务完成 // 世界任务完成
func (this *apiComp) FinishCheck(session comm.IUserSession, req *pb.WorldtaskFinishReq) (code pb.ErrorCode) { func (this *apiComp) FinishCheck(session comm.IUserSession, req *pb.WorldtaskFinishReq) (code pb.ErrorCode) {
if req.GroupId == 0 || req.TaskId == 0 { if req.GroupId == 0 || req.TaskId == 0 {
this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) this.module.Error("世界任务完成参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return