From 549be3d0baccacd03af1e244b292456cfd171248 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Fri, 8 Jul 2022 11:25:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B6=88=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/module.go | 67 +++++++++++++++++++++++------------------- modules/modulebase.go | 26 ++++++++-------- 2 files changed, 50 insertions(+), 43 deletions(-) diff --git a/modules/hero/module.go b/modules/hero/module.go index cd721ce13..98029e9dd 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -3,7 +3,6 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" ) @@ -45,32 +44,38 @@ func (this *Hero) CreateHero(uid string, heroCfgId ...int32) error { } //消耗英雄卡 -func (this *Hero) ConsumeCard(uId string, heroCfgId int32, count int32) (code pb.ErrorCode) { - if count <= 0 { - log.Errorf("attr no changed,uid: %s heroCfgId: %s count: %d", uId, heroCfgId, count) - code = pb.ErrorCode_ReqParameterError - return - } - heroes := this.GetHeroList(uId) - var curList []*pb.DBHero - for _, v := range heroes { - if heroCfgId == v.HeroID { - curList = append(curList, v) - } - } - if int32(len(curList)) < count { - return pb.ErrorCode_HeroNoEnough - } +// func (this *Hero) ConsumeCard(uId string, heroCfgId int32, count int32) (code pb.ErrorCode) { +// if count <= 0 { +// log.Errorf("attr no changed,uid: %s heroCfgId: %s count: %d", uId, heroCfgId, count) +// code = pb.ErrorCode_ReqParameterError +// return +// } - for _, v := range curList { - err := this.modelHero.consumeOneHeroCard(v.Uid, v.Id, count) - if err != nil { - return pb.ErrorCode_DBError - } - } +// heroCfg := this.configure.GetHero(heroCfgId) +// if heroCfg != nil { - return pb.ErrorCode_Success -} +// } + +// heroes := this.GetHeroList(uId) +// var curList []*pb.DBHero +// for _, v := range heroes { +// if heroCfgId == v.HeroID { +// curList = append(curList, v) +// } +// } +// if int32(len(curList)) < count { +// return pb.ErrorCode_HeroNoEnough +// } + +// for _, v := range curList { +// err := this.modelHero.consumeOneHeroCard(v.Uid, v.Id, count) +// if err != nil { +// return pb.ErrorCode_DBError +// } +// } + +// return pb.ErrorCode_Success +// } //获取英雄 func (this *Hero) GetHero(uid, heroId string) (*pb.DBHero, pb.ErrorCode) { @@ -110,13 +115,13 @@ func (this *Hero) UpdateEquipment(hero *pb.DBHero, equip []*pb.DB_Equipment) (co //英雄列表 func (this *Hero) GetHeroList(uid string) []*pb.DBHero { - data := []*pb.DBHero{} + // data := []*pb.DBHero{} heroes := this.modelHero.getHeroList(uid) - for _, h := range heroes { - h.Property = this.modelHero.PropertyCompute(uid, h.Id) - data = append(data, h) - } - return data + // for _, h := range heroes { + // h.Property = this.modelHero.PropertyCompute(uid, h.Id) + // data = append(data, h) + // } + return heroes } //查询英雄数量 diff --git a/modules/modulebase.go b/modules/modulebase.go index f8918b461..21c5d6d87 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -158,16 +158,17 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p code = pb.ErrorCode_ResNoEnough return } - } else if v.A == comm.HeroType { //卡片资源 - if resID, err = strconv.Atoi(v.T); err != nil { - code = pb.ErrorCode_ConfigurationException - return - } - if amount = int32(this.ModuleHero.QueryHeroAmount(uid, int32(resID))); amount < v.N { - code = pb.ErrorCode_ResNoEnough - return - } } + // else if v.A == comm.HeroType { //卡片资源 + // if resID, err = strconv.Atoi(v.T); err != nil { + // code = pb.ErrorCode_ConfigurationException + // return + // } + // if amount = int32(this.ModuleHero.QueryHeroAmount(uid, int32(resID))); amount < v.N { + // code = pb.ErrorCode_ResNoEnough + // return + // } + // } //不存在消耗武器的情况 // } else if v.A == comm.EquipmentType { // if resID, err = strconv.Atoi(v.T); err != nil { @@ -187,10 +188,11 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p } else if v.A == comm.ItemType { //道具资源 resID, _ = strconv.Atoi(v.T) this.ModuleItems.AddItem(source, uid, int32(resID), -1*v.N) - } else if v.A == comm.HeroType { //卡片资源 - resID, _ = strconv.Atoi(v.T) - this.ModuleHero.ConsumeCard(uid, int32(resID), -1*v.N) } + // else if v.A == comm.HeroType { //卡片资源 + // resID, _ = strconv.Atoi(v.T) + // this.ModuleHero.ConsumeCard(uid, int32(resID), -1*v.N) + // } // } else if v.A == comm.EquipmentType { // resID, _ = strconv.Atoi(v.T) // equipment.AddNewEquipments(source, uid, resID, -1*v.N)