坐骑资源接口优化
This commit is contained in:
parent
ab9ec2a86b
commit
47880f27d5
@ -36,6 +36,7 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
||||
err error
|
||||
dragon *pb.DBDragon
|
||||
chanegList []*pb.DBDragon
|
||||
bNewDragon bool // 是否是新的坐骑
|
||||
)
|
||||
dragonList := make([]*pb.DBDragon, 0)
|
||||
uid := session.GetUserId()
|
||||
@ -49,7 +50,22 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
||||
return
|
||||
}
|
||||
}
|
||||
if dbModel != nil {
|
||||
err = dbModel.GetList(uid, &dragonList)
|
||||
} else {
|
||||
err = this.GetList(uid, &dragonList)
|
||||
}
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
for dragonCfgId, lv := range dragons {
|
||||
bNewDragon = true
|
||||
if lv <= 0 {
|
||||
return
|
||||
}
|
||||
@ -61,27 +77,7 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
||||
}
|
||||
return
|
||||
}
|
||||
if dbModel != nil {
|
||||
if err = dbModel.GetList(uid, &dragonList); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError, // 配置没找到
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err = this.GetList(uid, &dragonList); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError, // 配置没找到
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
dragon = &pb.DBDragon{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: uid,
|
||||
@ -95,6 +91,7 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
||||
for _, obj := range dragonList {
|
||||
if obj.Dragonid == dragonCfgId { // 重复获得 直接返回
|
||||
dragon.Id = obj.Id
|
||||
bNewDragon = false
|
||||
update := make(map[string]interface{}, 0)
|
||||
update["lv"] = lv // 更新等级
|
||||
if err = this.UpdateDragonData(session.GetUserId(), obj.Id, update); err != nil {
|
||||
@ -108,7 +105,6 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if conf, err := this.module.configure.GetDragonConfById(dragonCfgId, lv); err == nil {
|
||||
if c, err := this.module.configure.GetDragonMount(dragonCfgId, conf.Type); err == nil {
|
||||
dragon.Property["stime"] = c.Stime
|
||||
@ -118,19 +114,27 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
||||
dragon.Property["sprint"] = c.Sprint
|
||||
dragon.Property["acceleration"] = c.Acceleration
|
||||
dragon.Property["deceleration"] = c.Deceleration
|
||||
// dragon.Property["itemsprint"] = c.Itemsprint
|
||||
dragon.Property["caddtime"] = c.Caddtime
|
||||
dragon.Property["csubtime"] = c.Csubtime
|
||||
}
|
||||
}
|
||||
|
||||
if !bNewDragon {
|
||||
continue
|
||||
}
|
||||
if dbModel != nil {
|
||||
if dbModel, err1 := this.module.GetDBModelByUid(uid, this.TableName); err1 == nil {
|
||||
err = dbModel.AddList(uid, dragonCfgId, dragon)
|
||||
}
|
||||
err = dbModel.AddList(uid, dragonCfgId, dragon)
|
||||
} else {
|
||||
err = this.AddList(uid, dragonCfgId, dragon)
|
||||
}
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
chanegList = append(chanegList, dragon)
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.DragonChangePush{
|
||||
|
Loading…
Reference in New Issue
Block a user