驯龙养成优化
This commit is contained in:
parent
b49cb804d2
commit
a1f7e39c9e
@ -47,6 +47,31 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if _, ok := dragon.Play[req.Ttype]; !ok {
|
||||||
|
dragon.Play[req.Ttype] = &pb.PlayData{
|
||||||
|
Count: 0,
|
||||||
|
Cdendtime: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if dragon.Play[req.Ttype].Cdendtime > configure.Now().Unix() { // cd时间冷却中
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DragonTrainCding,
|
||||||
|
Title: pb.ErrorCode_DragonTrainCding.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if playConf.Cd > 0 {
|
||||||
|
dragon.Play[req.Ttype].Cdendtime = configure.Now().Unix() + int64(playConf.Cd)
|
||||||
|
}
|
||||||
|
// 校验训练次数
|
||||||
|
if dragon.Play[req.Ttype].Count >= playConf.Time {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DragonTrainMaxCount,
|
||||||
|
Title: pb.ErrorCode_DragonTrainMaxCount.ToString(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
if conf, err := this.module.configure.GetDragonConfById(dragon.Dragonid, dragon.Lv); err == nil {
|
if conf, err := this.module.configure.GetDragonConfById(dragon.Dragonid, dragon.Lv); err == nil {
|
||||||
if playConf, err = this.module.configure.GetDragonPlayConfById(dragon.Dragonid, conf.Type, req.Ttype); err == nil {
|
if playConf, err = this.module.configure.GetDragonPlayConfById(dragon.Dragonid, conf.Type, req.Ttype); err == nil {
|
||||||
// 校验消耗
|
// 校验消耗
|
||||||
@ -94,54 +119,6 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if curType != preType { // 坐骑升阶 增加属性
|
|
||||||
if c, err := this.module.configure.GetDragonMount(dragon.Dragonid, curType); err != nil {
|
|
||||||
dragon.Property = make(map[string]int32)
|
|
||||||
dragon.Property["stime"] = c.Stime
|
|
||||||
dragon.Property["etime"] = c.Etime
|
|
||||||
dragon.Property["hp"] = c.Hp
|
|
||||||
dragon.Property["moderate"] = c.Moderate
|
|
||||||
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
|
|
||||||
update["property"] = dragon.Property // 更新属性
|
|
||||||
}
|
|
||||||
// 升阶后重置养成属性次数
|
|
||||||
dragon.Play = make(map[int32]*pb.PlayData)
|
|
||||||
update["play"] = dragon.Play
|
|
||||||
}
|
|
||||||
if speed > 0 { // 更新最大速度
|
|
||||||
dragon.Property["etime"] = speed
|
|
||||||
update["property"] = dragon.Property
|
|
||||||
}
|
|
||||||
if _, ok := dragon.Play[req.Ttype]; !ok {
|
|
||||||
dragon.Play[req.Ttype] = &pb.PlayData{
|
|
||||||
Count: 0,
|
|
||||||
Cdendtime: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if dragon.Play[req.Ttype].Cdendtime > configure.Now().Unix() { // cd时间冷却中
|
|
||||||
errdata = &pb.ErrorData{
|
|
||||||
Code: pb.ErrorCode_DragonTrainCding,
|
|
||||||
Title: pb.ErrorCode_DragonTrainCding.ToString(),
|
|
||||||
Message: err.Error(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if playConf.Cd > 0 {
|
|
||||||
dragon.Play[req.Ttype].Cdendtime = configure.Now().Unix() + int64(playConf.Cd)
|
|
||||||
}
|
|
||||||
// 校验训练次数
|
|
||||||
if dragon.Play[req.Ttype].Count >= playConf.Time {
|
|
||||||
errdata = &pb.ErrorData{
|
|
||||||
Code: pb.ErrorCode_DragonTrainMaxCount,
|
|
||||||
Title: pb.ErrorCode_DragonTrainMaxCount.ToString(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dragon.Play[req.Ttype].Count += 1 // 次数+1
|
dragon.Play[req.Ttype].Count += 1 // 次数+1
|
||||||
update["play"] = dragon.Play
|
update["play"] = dragon.Play
|
||||||
|
|
||||||
@ -154,6 +131,28 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e
|
|||||||
}
|
}
|
||||||
rsp.Reward = atno
|
rsp.Reward = atno
|
||||||
}
|
}
|
||||||
|
if curType != preType { // 坐骑升阶 增加属性
|
||||||
|
if c, err := this.module.configure.GetDragonMount(dragon.Dragonid, curType); err != nil {
|
||||||
|
dragon.Property = make(map[string]int32)
|
||||||
|
dragon.Property["stime"] = c.Stime
|
||||||
|
dragon.Property["etime"] = c.Etime
|
||||||
|
dragon.Property["hp"] = c.Hp
|
||||||
|
dragon.Property["moderate"] = c.Moderate
|
||||||
|
dragon.Property["sprint"] = c.Sprint
|
||||||
|
dragon.Property["acceleration"] = c.Acceleration
|
||||||
|
dragon.Property["deceleration"] = c.Deceleration
|
||||||
|
dragon.Property["caddtime"] = c.Caddtime
|
||||||
|
dragon.Property["csubtime"] = c.Csubtime
|
||||||
|
update["property"] = dragon.Property // 更新属性
|
||||||
|
}
|
||||||
|
// 升阶后重置养成属性次数
|
||||||
|
dragon.Play = make(map[int32]*pb.PlayData)
|
||||||
|
update["play"] = dragon.Play
|
||||||
|
}
|
||||||
|
if speed > dragon.Property["etime"] { // 更新最大速度
|
||||||
|
dragon.Property["etime"] = speed
|
||||||
|
update["property"] = dragon.Property
|
||||||
|
}
|
||||||
rsp.Dragons = dragon
|
rsp.Dragons = dragon
|
||||||
this.module.modelDragon.UpdateDragonData(session.GetUserId(), dragon.Id, update)
|
this.module.modelDragon.UpdateDragonData(session.GetUserId(), dragon.Id, update)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user