上传装备添加多个叠加bug

This commit is contained in:
liwei1dao 2022-10-09 16:01:05 +08:00
parent 2a69fe0450
commit fa78695a20

View File

@ -78,35 +78,36 @@ 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
// equipments []*pb.DB_Equipment
// iskeep bool
add map[string]*pb.DB_Equipment
update 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 {
// 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 {
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),
}