From 9662b6f512b3e855f7e5b70386a499ae60fbb97a Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 1 Sep 2023 14:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9D=90=E9=AA=91=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 14 ++++++++++ modules/dragon/api_train.go | 56 +++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/comm/const.go b/comm/const.go index 798b67c67..ad01d51dc 100644 --- a/comm/const.go +++ b/comm/const.go @@ -1034,3 +1034,17 @@ const ( SmithyToolsSkill4 = 4 // 每日顾客数量提升至{0}人 SmithyToolsSkill5 = 5 // 顾客购买装备数量上限提高至{0}件 ) + +// 坐骑属性 +const ( + Stime string = "stime" + Etime string = "etime" + Dhp string = "hp" + Moderate string = "moderate" + Sprint string = "sprint" + Acceleration string = "acceleration" + Deceleration string = "deceleration" + Itemsprint string = "itemsprint" + Caddtime string = "caddtime" + Csubtime string = "csubtime" +) diff --git a/modules/dragon/api_train.go b/modules/dragon/api_train.go index 704b4ac46..1349df1f1 100644 --- a/modules/dragon/api_train.go +++ b/modules/dragon/api_train.go @@ -19,11 +19,17 @@ func (this *apiComp) TrainCheck(session comm.IUserSession, req *pb.DragonTrainRe func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (errdata *pb.ErrorData) { var ( - err error - dragon *pb.DBDragon - //addExp int32 // 获得的训练值 + err error + dragon *pb.DBDragon playConf *cfg.GameDragonPlayData update map[string]interface{} + preType int32 + curType int32 // 当前阶段 + reward []*cfg.Gameatn + preLv int32 // 升级之前的等级 + curLv int32 // 升级之后的等级 + atno []*pb.UserAtno + speed int32 ) update = make(map[string]interface{}) rsp := &pb.DragonTrainResp{} @@ -40,7 +46,6 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e } 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 { - //addExp = playConf.Exp // 校验消耗 if errdata = this.module.CheckRes(session, playConf.Deplete); errdata != nil { return @@ -53,13 +58,17 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e } return } - + preLv = dragon.Lv + preType = conf.Type dragon.Exp += playConf.Exp // 加经验 - for { if dragon.Exp >= conf.Exp { dragon.Lv += 1 dragon.Exp -= conf.Exp + if len(conf.Reward) > 0 { + reward = append(reward, conf.Reward...) + } + speed = conf.Etime if conf, err = this.module.configure.GetDragonConfById(dragon.Dragonid, dragon.Lv); err != nil { dragon.Lv -= 1 dragon.Exp += conf.Exp @@ -69,6 +78,31 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e break } } + update["exp"] = dragon.Exp + update["lv"] = dragon.Lv + curType = conf.Type + curLv = dragon.Lv + } + + 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 // 更新属性 + } + } + if speed > 0 { // 更新最大速度 + dragon.Property["etime"] = speed + update["property"] = dragon.Property } // 校验训练次数 @@ -77,6 +111,16 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e } dragon.Play[req.Ttype] += 1 // 次数+1 update["play"] = dragon.Play + + if errdata = this.module.ConsumeRes(session, playConf.Deplete, true); errdata != nil { + return + } + if curLv > preLv && len(reward) > 0 { // 看看有没有升级奖励 + if errdata, atno = this.module.DispenseAtno(session, reward, true); errdata != nil { + return + } + rsp.Reward = atno + } this.module.modelDragon.UpdateDragonData(session.GetUserId(), dragon.Id, update) session.SendMsg(string(this.module.GetType()), "", rsp) return