From 253b901833ca86855c0daafdbbce936659182cf4 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 8 Dec 2023 13:43:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_stonestage.json | 2 +- comm/imodule.go | 3 ++ modules/integral/api_getlist.go | 17 +++++++++ modules/integral/model_integral.go | 23 +++++++------ modules/integral/module.go | 55 ++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 11 deletions(-) diff --git a/bin/json/game_stonestage.json b/bin/json/game_stonestage.json index 3c411e696..d37b91698 100644 --- a/bin/json/game_stonestage.json +++ b/bin/json/game_stonestage.json @@ -6,7 +6,7 @@ "PreviouStage": 0, "StageName": { "key": "stonehenge_stageconfig_StageName_1", - "text": "石阵1" + "text": "石阵2" }, "RoomId": 1, "RoomGroup": 110100, diff --git a/comm/imodule.go b/comm/imodule.go index e7e5cc5ba..3f0387df1 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -710,4 +710,7 @@ type ( IIsland interface { IPayDelivery } + IIntegral interface { + IBuriedUpdateNotify + } ) diff --git a/modules/integral/api_getlist.go b/modules/integral/api_getlist.go index dcd952902..0549c455f 100644 --- a/modules/integral/api_getlist.go +++ b/modules/integral/api_getlist.go @@ -75,6 +75,23 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.IntegralGetListR update["reward2"] = list.Reward2 update["buff"] = list.Buff update["score"] = list.Score + + if list.Itype == 2 { + var szTaskid []int32 + for _, v := range this.module.configure.GetIntegralCondition() { + szTaskid = append(szTaskid, v.TaskId) // 获取任务id + } + if data, err := this.module.ModuleBuried.CheckCondition(session.GetUserId(), szTaskid...); err == nil { + for _, v := range data { + + if v.State == pb.BuriedItemFinishState_buried_finish { + if c, e := this.module.configure.GetIntegralConditionByTask(v.Conid); e == nil { + list.Buff[v.Conid] = c.Id + } + } + } + } + } } if len(update) > 0 { if err = this.module.modelIntegral.modifyIntegralData(session.GetUserId(), update); err != nil { diff --git a/modules/integral/model_integral.go b/modules/integral/model_integral.go index bd15aa185..f7b3abe31 100644 --- a/modules/integral/model_integral.go +++ b/modules/integral/model_integral.go @@ -60,18 +60,21 @@ func (this *modelIntegral) getIntegralList(uid string) (result *pb.DBIntegralBos var conf *cfg.GameIntegralBossData if conf, err = this.module.configure.GetStageBoss(result.Hid, 1); err == nil { - result.Itype = conf.Itype // 获取类型 + result.Itype = conf.Itype // 获取类型 1 难度模式 2 事件模式 result.Nandu = 1 // 初始难度1 - var szTaskid []int32 - for _, v := range this.module.configure.GetIntegralCondition() { - szTaskid = append(szTaskid, v.TaskId) // 获取任务id - } - if data, err := this.module.ModuleBuried.CheckCondition(uid, szTaskid...); err == nil { - for _, v := range data { + // 只有 事件模式才有buff + if result.Itype == 2 { + var szTaskid []int32 + for _, v := range this.module.configure.GetIntegralCondition() { + szTaskid = append(szTaskid, v.TaskId) // 获取任务id + } + if data, err := this.module.ModuleBuried.CheckCondition(uid, szTaskid...); err == nil { + for _, v := range data { - if v.State == pb.BuriedItemFinishState_buried_finish { - if c, e := this.module.configure.GetIntegralConditionByTask(v.Conid); e == nil { - result.Buff[v.Conid] = c.Id + if v.State == pb.BuriedItemFinishState_buried_finish { + if c, e := this.module.configure.GetIntegralConditionByTask(v.Conid); e == nil { + result.Buff[v.Conid] = c.Id + } } } } diff --git a/modules/integral/module.go b/modules/integral/module.go index 8471e3d48..e6899a24c 100644 --- a/modules/integral/module.go +++ b/modules/integral/module.go @@ -4,7 +4,9 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" + "go_dreamfactory/pb" ) type Integral struct { @@ -52,3 +54,56 @@ func (this *Integral) OnInstallComp() { this.modelIntegral = this.RegisterComp(new(modelIntegral)).(*modelIntegral) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } + +// 任务条件达成通知 +func (this *Integral) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) { + var bChange bool + this.Debug("积分bossm条件达成通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds}) + dt, err := this.modelIntegral.getIntegralList(session.GetUserId()) + + if dt.Itype != 2 { // 只有事件模式才有debuff + return + } + confList := this.configure.GetIntegralCondition() + if err != nil { + this.Error(err.Error()) + return + } + condMap := make(map[int32]*pb.ConIProgress) + for _, conf := range confList { + for _, cond := range conds { + if cond.Conid == conf.TaskId { + condMap[conf.TaskId] = cond + } + } + } + update := make(map[string]interface{}) + + if dt.Buff == nil { + dt.Buff = make(map[int32]int32) + for _, v := range condMap { + if v.State == pb.BuriedItemFinishState_buried_finish { + if c, err := this.configure.GetIntegralConditionByTask(v.Conid); err == nil { + dt.Buff[c.Id] = 1 + bChange = true + } + } + } + } + + for k, v := range condMap { + if dt.Buff[k] != 1 && v.State == pb.BuriedItemFinishState_buried_finish { + dt.Buff[k] = 1 + bChange = true + + } + } + if bChange { + update["buff"] = dt.Buff + if err := this.modelIntegral.modifyIntegralData(session.GetUserId(), update); err != nil { + this.Error(err.Error()) + return + } + } + return +}