From d4f1df7e7766ccad84ff96da3e9db5f359938cdf Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 16 Aug 2023 16:01:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=BA=95=E5=B1=82=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/modulebase.go | 126 +++++++++++++++++++++++++++++++++++------- 1 file changed, 105 insertions(+), 21 deletions(-) diff --git a/modules/modulebase.go b/modules/modulebase.go index 049a0679b..28506fee9 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -646,17 +646,28 @@ func (this *ModuleBase) Panicln(args ...interface{}) { // 发放资源 func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gameatn, bPush bool) (errdata *pb.ErrorData, atno []*pb.UserAtno) { var ( - items map[string]int32 // 道具背包 批量处理 - heros map[string]int32 // 英雄 - attrs map[string]int32 // 属性 - equips map[string]uint32 // 装备 - vip map[string]int32 // vip + items map[string]int32 // 道具背包 批量处理 + heros map[string]int32 // 英雄 + attrs map[string]int32 // 属性 + equips map[string]uint32 // 装备 + vip map[string]int32 // vip + atlas map[string]int32 // 铁匠铺资源 + panda map[string]int32 // 熊猫武馆资源 + mts map[string]int32 // 捕羊大赛资源 + per map[string]int32 // 捕羊大赛资源 + equipschange []*pb.DB_Equipment + heroschange []*pb.UserAtno + itemschange []*pb.UserAtno ) items = make(map[string]int32, 0) heros = make(map[string]int32, 0) attrs = make(map[string]int32, 0) equips = make(map[string]uint32, 0) vip = make(map[string]int32, 0) + atlas = make(map[string]int32, 0) + panda = make(map[string]int32, 0) + mts = make(map[string]int32, 0) + per = make(map[string]int32, 0) for _, v := range res { switch v.A { @@ -672,38 +683,52 @@ func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gamea } case comm.VipType: vip[v.T] += v.N + case comm.AtlasType: + atlas[v.T] = 1 + case comm.PandaType: + panda[v.T] = 1 + case comm.MountsType: + mts[v.T] = 1 + case comm.PerType: + per[v.T] = 1 default: this.Error("not found res type", log.Field{Key: "Type", Value: v.A}) // 找不到资源类型 } } if len(attrs) > 0 { //用户属性资源 - errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush) - this.Debugf("发放用户资源: %v [%v]", attrs, errdata) + if errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush); errdata != nil { + return + } for k, v := range attrs { atno = append(atno, &pb.UserAtno{ - A: "attr", + A: comm.AttrType, T: k, N: v, - O: "", }) } + this.Debugf("发放用户资源: %v errdata: %v", attrs, errdata) + } if len(items) > 0 { //道具资源 - _atno, code := this.ModuleItems.AddItems(session, items, bPush) - errdata = code - atno = append(atno, _atno...) - this.Debugf("发放道具资源: %v [%v]", _atno, code) + if itemschange, errdata = this.ModuleItems.AddItems(session, items, bPush); errdata != nil { + return + } + atno = append(atno, itemschange...) + this.Debugf("发放道具资源: %v errdata: %v", items, errdata) } if len(heros) > 0 { //卡片资源 - hero, atn, code := this.ModuleHero.CreateRepeatHeros(session, heros, bPush) - this.Debugf("发放英雄资源: %v [%v]", hero, code) - atno = append(atno, atn...) + if _, heroschange, errdata = this.ModuleHero.CreateRepeatHeros(session, heros, bPush); errdata != nil { + return + } + atno = append(atno, heroschange...) + this.Debugf("发放英雄资源: %v errdata: %v", heros, errdata) } if len(equips) > 0 { - change, code := this.ModuleEquipment.AddNewEquipments(session, equips, bPush) - this.Debugf("发放装备资源: %v [%v]", equips, code) - for _, v := range change { + if equipschange, errdata = this.ModuleEquipment.AddNewEquipments(session, equips, bPush); errdata != nil { + return + } + for _, v := range equipschange { atno = append(atno, &pb.UserAtno{ A: "equi", T: v.CId, @@ -711,13 +736,72 @@ func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gamea O: v.Id, }) } + this.Debugf("发放装备资源: %v errdata: %v", equips, errdata) } if len(vip) > 0 { //卡片资源 for k := range vip { errdata, _ = this.ModulePrivilege.Delivery(session, k) - this.Debugf("发放月卡资源: %v [%v]", k, errdata) + this.Debugf("发放月卡资源: %v errdata: %v", k, errdata) } - + for k, v := range vip { + atno = append(atno, &pb.UserAtno{ + A: comm.VipType, + T: k, + N: v, + }) + } + } + if len(atlas) > 0 { + for k := range atlas { + this.ModuleSmithy.CheckActivateAtlasCollect(session.GetUserId(), k) + this.Debugf("发放图鉴资源: %v errdata: %v", k, errdata) + } + for k, v := range atlas { + atno = append(atno, &pb.UserAtno{ + A: comm.AtlasType, + T: k, + N: v, + }) + } + } + if len(panda) > 0 { + if errdata = this.ModulePractice.AddItems(session, panda, bPush); errdata != nil { + return + } + for k, v := range panda { + atno = append(atno, &pb.UserAtno{ + A: comm.PandaType, + T: k, + N: v, + }) + } + this.Debugf("发放武馆资源: %v errdata: %v", panda, errdata) + } + if len(mts) > 0 { + if errdata = this.ModuleParkour.AddMounts(session, mts, bPush); errdata != nil { + return + } + for k, v := range mts { + atno = append(atno, &pb.UserAtno{ + A: comm.MountsType, + T: k, + N: v, + }) + } + this.Debugf("发放捕羊大赛资源: %v errdata: %v", mts, errdata) + } + if len(per) > 0 { + if errdata = this.ModuleUser.AddPer(session, per, bPush); errdata != nil { + return + } + for k, v := range per { + atno = append(atno, &pb.UserAtno{ + A: comm.PerType, + T: k, + N: v, + }) + } + this.Debugf("发放用户皮肤资源资源: %v errdata: %v", mts, errdata) } return }