From fa78695a2056009f924324139c14f51633458b3e Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Sun, 9 Oct 2022 16:01:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A3=85=E5=A4=87=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A4=9A=E4=B8=AA=E5=8F=A0=E5=8A=A0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/equipment/modelEquipment.go | 67 +++++++++++++++-------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/modules/equipment/modelEquipment.go b/modules/equipment/modelEquipment.go index 981e8745e..62aac4bc2 100644 --- a/modules/equipment/modelEquipment.go +++ b/modules/equipment/modelEquipment.go @@ -77,36 +77,37 @@ func (this *modelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId str //添加装备 func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds map[string]uint32) (change []*pb.DB_Equipment, err error) { var ( - configure *cfg.GameEquip - equipments []*pb.DB_Equipment - iskeep bool - add map[string]*pb.DB_Equipment - update map[string]*pb.DB_Equipment - uId string = session.GetUserId() + configure *cfg.GameEquip + // equipments []*pb.DB_Equipment + // iskeep bool + add map[string]*pb.DB_Equipment + // update map[string]*pb.DB_Equipment + uId string = session.GetUserId() ) if configure, err = this.module.configure.GetEquipmentConfigure(); err != nil { return } - if equipments, err = this.QueryUserEquipments(uId); err != nil { - return - } + // if equipments, err = this.QueryUserEquipments(uId); err != nil { + // return + // } add = make(map[string]*pb.DB_Equipment) - update = make(map[string]*pb.DB_Equipment) - change = make([]*pb.DB_Equipment, 0, len(equipments)) + // update = make(map[string]*pb.DB_Equipment) + change = make([]*pb.DB_Equipment, 0, 10) for k, v := range cIds { - iskeep = false - for _, equipment := range equipments { - if equipment.CId == k && equipment.IsInitialState { - update[equipment.Id] = equipment - change = append(change, equipment) - equipment.OverlayNum += v - iskeep = true - break - } - } - if !iskeep { - if c, ok := configure.GetDataMap()[k]; ok { - if equipment, err := this.newEquipment(uId, c, v); err != nil { + // iskeep = false + // for _, equipment := range equipments { + // if equipment.CId == k && equipment.IsInitialState { + // update[equipment.Id] = equipment + // change = append(change, equipment) + // equipment.OverlayNum += v + // iskeep = true + // break + // } + // } + // if !iskeep { + if c, ok := configure.GetDataMap()[k]; ok { + for i := uint32(0); i < v; i++ { + if equipment, err := this.newEquipment(uId, c); err != nil { return nil, err } else { //随机任务 @@ -115,7 +116,9 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma change = append(change, equipment) } } + } + // } } if len(add) > 0 { if err = this.AddLists(uId, add); err != nil { @@ -124,12 +127,12 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma } } - for _, v := range update { - if err = this.ChangeList(uId, v.Id, map[string]interface{}{"overlayNum": v.OverlayNum}); err != nil { - log.Errorf("err:%v", err) - return - } - } + // for _, v := range update { + // if err = this.ChangeList(uId, v.Id, map[string]interface{}{"overlayNum": v.OverlayNum}); err != nil { + // log.Errorf("err:%v", err) + // return + // } + // } return } @@ -164,7 +167,7 @@ func (this *modelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_ } //创建新的武器对象 -func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.GameEquipData, num uint32) (equipment *pb.DB_Equipment, err error) { +func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.GameEquipData) (equipment *pb.DB_Equipment, err error) { var ( mattr []*cfg.GameEquipAttrlibraryData sattr []*cfg.GameEquipAttrlibraryData @@ -176,7 +179,7 @@ func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.GameEquipData CId: conf.Id, Lv: 1, UId: uid, - OverlayNum: num, + OverlayNum: 1, IsInitialState: false, AdverbEntry: make([]*pb.EquipmentAttributeEntry, 0), }