From 8350d34412bd1de1ef0ec6c52be1ebbc347a60b7 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 15 Nov 2023 10:11:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A4=E6=9C=88=E7=AD=89=E7=BA=A7=E6=AF=8F?= =?UTF-8?q?=E4=B8=AA=E7=AD=89=E7=BA=A7=E4=BB=BB=E5=8A=A1=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/moonlv/api_lvaward.go | 24 ++++++++++++++++++++++- modules/moonlv/model_moonlv.go | 36 +++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/modules/moonlv/api_lvaward.go b/modules/moonlv/api_lvaward.go index bc2d9e88e..1d2721cc7 100644 --- a/modules/moonlv/api_lvaward.go +++ b/modules/moonlv/api_lvaward.go @@ -52,7 +52,29 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.MoonlvAwardReq) (e update["lv"] = list.Lv // 升级了清空当前任务 list.Tasks = nil - update["task"] = list.Tasks + // 重置任务 + var szTaskid []int32 + if lvConf, err := this.module.configure.GetMoonLvConf(list.Lv); err != nil { + if conf, err := this.module.configure.GetMoonLvTaskConf(lvConf.TaskGroupId); err != nil { + for _, v := range conf { + szTaskid = append(szTaskid, v.TaskId) // 获取任务id + } + } + } + if data, err := this.module.ModuleBuried.CheckCondition(session.GetUserId(), szTaskid...); err == nil { + for _, v := range data { + tmp := &pb.MoonTask{ + TaskId: v.Conid, + Received: 0, + Cond: v, + } + if v.State == pb.BuriedItemFinishState_buried_finish { + tmp.Received = 1 + } + list.Tasks = append(list.Tasks, tmp) + } + } + update["tasks"] = list.Tasks } list.Reward[req.Lv] = true update["reward"] = list.Reward diff --git a/modules/moonlv/model_moonlv.go b/modules/moonlv/model_moonlv.go index a78b82f8f..271d5f03a 100644 --- a/modules/moonlv/model_moonlv.go +++ b/modules/moonlv/model_moonlv.go @@ -35,6 +35,27 @@ func (this *modelMoonlv) getMoonlvList(uid string) (result *pb.DBMoonLv, err err result.Uid = uid result.Lv = 1 // 默认1级 result.Reward = make(map[int32]bool) + var szTaskid []int32 + if lvConf, err := this.module.configure.GetMoonLvConf(1); err != nil { + if conf, err := this.module.configure.GetMoonLvTaskConf(lvConf.TaskGroupId); err != nil { + for _, v := range conf { + szTaskid = append(szTaskid, v.TaskId) // 获取任务id + } + } + } + if data, err := this.module.ModuleBuried.CheckCondition(uid, szTaskid...); err == nil { + for _, v := range data { + tmp := &pb.MoonTask{ + TaskId: v.Conid, + Received: 0, + Cond: v, + } + if v.State == pb.BuriedItemFinishState_buried_finish { + tmp.Received = 1 + } + result.Tasks = append(result.Tasks, tmp) + } + } this.Add(uid, result) err = nil } @@ -46,13 +67,14 @@ func (this *modelMoonlv) getMoonlvList(uid string) (result *pb.DBMoonLv, err err func (this *modelMoonlv) modifyMoonlvList(uid string, data map[string]interface{}) error { return this.Change(uid, data) } -func (this *modelMoonlv) getTaskRecord(uid string) (*pb.DBTujianTask, error) { - tt := &pb.DBTujianTask{Uid: uid} - if err := this.Get(uid, tt); err != nil { - return tt, err - } - return tt, nil -} + +// func (this *modelMoonlv) getTaskRecord(uid string) (*pb.DBTujianTask, error) { +// tt := &pb.DBTujianTask{Uid: uid} +// if err := this.Get(uid, tt); err != nil { +// return tt, err +// } +// return tt, nil +// } func (this *modelMoonlv) updateTaskRecord(uid string, taskId int32, dt *pb.DBMoonLv) error {