errdata 对象返回
This commit is contained in:
parent
42becbca4e
commit
04a478e3a9
@ -65,15 +65,18 @@ func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCity
|
||||
// list.Task = event.Worldtask // 对应世界任务组
|
||||
// }
|
||||
} else {
|
||||
code = pb.ErrorCode_DataNotFound
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: e.Error(),
|
||||
}
|
||||
}
|
||||
}
|
||||
if list.Curcity == req.City {
|
||||
code = pb.ErrorCode_TrollCity
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TrollCity,
|
||||
Title: pb.ErrorCode_TrollCity.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// 校验门票
|
||||
|
@ -33,11 +33,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (e
|
||||
)
|
||||
_heroMap = make(map[string]interface{}, 0)
|
||||
chanegCard = make([]*pb.DBHero, 0)
|
||||
code = this.AwakenCheck(session, req) // check
|
||||
if errdata != nil {
|
||||
if errdata = this.AwakenCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
_hero, code = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID)
|
||||
_hero, errdata = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID)
|
||||
if errdata != nil {
|
||||
return
|
||||
}
|
||||
@ -49,10 +48,6 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (e
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(awakenData.Phasebonus) < 2 { // 配置校验
|
||||
@ -66,12 +61,14 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (e
|
||||
|
||||
//条件判断
|
||||
if awakenData.Condition > _hero.Lv {
|
||||
code = pb.ErrorCode_HeroLvNoEnough
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroLvNoEnough,
|
||||
Title: pb.ErrorCode_HeroLvNoEnough.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// 消耗校验
|
||||
code = this.module.ConsumeRes(session, awakenData.Phaseneed, true)
|
||||
if errdata != nil {
|
||||
if errdata = this.module.ConsumeRes(session, awakenData.Phaseneed, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -166,10 +163,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (e
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), szTask...)
|
||||
|
@ -39,7 +39,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (errdata
|
||||
return
|
||||
}
|
||||
if udata = this.module.ModuleUser.GetUser(session.GetUserId()); udata == nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNofound, // 没找到玩家数据
|
||||
Title: pb.ErrorCode_UserNofound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -49,16 +53,15 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (errdata
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
record, err := this.module.modelRecord.GetHeroRecord(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist, // 没找到英雄扩展数据数据
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
global = this.module.ModuleTools.GetGlobalConf()
|
||||
@ -80,8 +83,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (errdata
|
||||
}
|
||||
return
|
||||
}
|
||||
if totalCount > conf.Buymaxnum { // 购买达到上限
|
||||
code = pb.ErrorCode_ShopGoodsIsSoldOut
|
||||
if totalCount > conf.Buymaxnum {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ShopGoodsIsSoldOut, // 购买达到上限
|
||||
Title: pb.ErrorCode_ShopGoodsIsSoldOut.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
cfgDraw *cfg.GameGlobalData
|
||||
costAtn *cfg.Gameatn
|
||||
heroRecord *pb.DBHeroRecord
|
||||
pool string // 当前抽对应的卡池
|
||||
|
||||
strPool []string // 10连跨多个卡池情况
|
||||
pool string // 当前抽对应的卡池
|
||||
atno []*pb.UserAtno // 最终获得的资源
|
||||
strPool []string // 10连跨多个卡池情况
|
||||
update map[string]interface{}
|
||||
normalDraw bool // 是否是普通抽
|
||||
)
|
||||
@ -41,8 +41,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
if cfgDraw == nil {
|
||||
return
|
||||
}
|
||||
code = this.DrawCardCheck(session, req)
|
||||
if errdata != nil {
|
||||
if errdata = this.DrawCardCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
szCards = make([]string, 0)
|
||||
@ -59,8 +58,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
costAtn = cfgDraw.BasePool10cost
|
||||
}
|
||||
costRes = append(costRes, costAtn)
|
||||
code = this.module.CheckRes(session, costRes)
|
||||
if errdata != nil { // 消耗数量不足直接返回
|
||||
if errdata = this.module.CheckRes(session, costRes); errdata != nil { // 消耗数量不足直接返回
|
||||
return
|
||||
}
|
||||
|
||||
@ -245,8 +243,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
costRes = append(costRes, costAtn)
|
||||
|
||||
//阵营消耗
|
||||
code = this.module.CheckRes(session, costRes)
|
||||
if errdata != nil { // 消耗数量不足直接返回
|
||||
if errdata = this.module.CheckRes(session, costRes); errdata != nil { // 消耗数量不足直接返回
|
||||
return
|
||||
}
|
||||
for {
|
||||
@ -276,10 +273,6 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
sz := make([]int32, 0)
|
||||
@ -314,8 +307,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
}
|
||||
|
||||
// 消耗道具
|
||||
code = this.module.ConsumeRes(session, costRes, true)
|
||||
if errdata != nil {
|
||||
if errdata = this.module.ConsumeRes(session, costRes, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
heroRecord.Totalcount += req.DrawCount
|
||||
@ -329,30 +321,30 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
rsp := &pb.HeroDrawCardResp{
|
||||
Data: []*pb.AtnoData{},
|
||||
}
|
||||
var addRes []*cfg.Gameatn
|
||||
for _, heroId := range szCards {
|
||||
|
||||
res := &cfg.Gameatn{
|
||||
addRes = append(addRes, &cfg.Gameatn{
|
||||
A: "hero",
|
||||
T: heroId,
|
||||
N: 1,
|
||||
}
|
||||
if code, atno := this.module.DispenseAtno(session, []*cfg.Gameatn{res}, true); code == pb.ErrorCode_Success {
|
||||
})
|
||||
}
|
||||
|
||||
rsp.Data = append(rsp.Data, &pb.AtnoData{
|
||||
Atno: atno,
|
||||
})
|
||||
for _, v := range atno {
|
||||
if v.A == "hero" && v.N == 1 {
|
||||
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { // 广播 首次获得英雄
|
||||
this.chat.SendSysChatToWorld(comm.ChatSystem13, nil, 0, 0, user.Name, v.T)
|
||||
}
|
||||
if errdata, atno = this.module.DispenseAtno(session, addRes, true); errdata == nil {
|
||||
|
||||
rsp.Data = append(rsp.Data, &pb.AtnoData{Atno: atno})
|
||||
for _, v := range atno {
|
||||
if v.A == "hero" && v.N == 1 {
|
||||
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { // 广播 首次获得英雄
|
||||
this.chat.SendSysChatToWorld(comm.ChatSystem13, nil, 0, 0, user.Name, v.T)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), DrawCard, rsp)
|
||||
|
||||
// 任务统计
|
||||
this.module.SendTaskMsg(session, szStar, req.DrawCount, normalDraw)
|
||||
return
|
||||
|
@ -34,13 +34,9 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (e
|
||||
conf, err := this.module.configure.GetHeroFucionConfig(req.HeroId)
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Code: pb.ErrorCode_ConfigNoFound, // 配置没找到
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
} // 配置没找到
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -57,8 +53,9 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (e
|
||||
for k, v := range req.Heros {
|
||||
// 校验英雄是否存在
|
||||
_obj, c := this.module.GetHeroByObjID(session.GetUserId(), k)
|
||||
if c != pb.ErrorCode_Success || _obj.SameCount < v {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
if c != nil || _obj.SameCount < v {
|
||||
errdata = c
|
||||
return
|
||||
}
|
||||
mapHero[_obj.HeroID] += v
|
||||
_costMaphero[k] = _obj
|
||||
@ -85,8 +82,7 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (e
|
||||
}
|
||||
for k, v := range req.Heros {
|
||||
//mapHero[_costMaphero[k].HeroID]
|
||||
code = this.module.DelCard(session.GetUserId(), _costMaphero[k], v)
|
||||
if errdata != nil {
|
||||
if errdata = this.module.DelCard(session.GetUserId(), _costMaphero[k], v); errdata != nil {
|
||||
return
|
||||
}
|
||||
ChangeList = append(ChangeList, _costMaphero[k])
|
||||
@ -99,9 +95,8 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (e
|
||||
N: 1,
|
||||
}
|
||||
if errdata = this.module.DispenseRes(session, []*cfg.Gameatn{res}, false); errdata != nil {
|
||||
|
||||
this.module.Errorf("err:%v,create hero:%s,uid,%ss", code, conf.Hero, session.GetUserId())
|
||||
code = pb.ErrorCode_HeroCreate // 创建新英雄失败
|
||||
this.module.Errorf("err:%v,create hero:%s,uid,%ss", errdata, conf.Hero, session.GetUserId())
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), HeroFusionResp, &pb.HeroFusionResp{Heroid: conf.Hero})
|
||||
// 通过融合获得指定英雄
|
||||
|
@ -24,12 +24,10 @@ func (this *apiComp) Lock(session comm.IUserSession, req *pb.HeroLockReq) (errda
|
||||
var (
|
||||
_hero *pb.DBHero
|
||||
)
|
||||
code = this.LockCheck(session, req) // check
|
||||
if errdata != nil {
|
||||
if errdata = this.LockCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
_hero, code = this.module.GetHeroByObjID(session.GetUserId(), req.Heroid)
|
||||
if errdata != nil {
|
||||
if _hero, errdata = this.module.GetHeroByObjID(session.GetUserId(), req.Heroid); errdata != nil {
|
||||
return
|
||||
}
|
||||
_hero.Block = !_hero.Block // 修改是否锁定状态
|
||||
|
@ -22,13 +22,16 @@ func (this *apiComp) GetSpecifiedCheck(session comm.IUserSession, req *pb.HeroGe
|
||||
/// 获取指定星级或等级的英雄 GM 协议
|
||||
func (this *apiComp) GetSpecified(session comm.IUserSession, req *pb.HeroGetSpecifiedReq) (errdata *pb.ErrorData) {
|
||||
|
||||
code = this.GetSpecifiedCheck(session, req) // check
|
||||
if errdata != nil {
|
||||
if errdata = this.GetSpecifiedCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
hero, err := this.module.modelHero.createSpecialHero(session.GetUserId(), req.HeroCoinfigID)
|
||||
if err == nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
hero.Lv = req.Lv
|
||||
hero.Star = req.Star
|
||||
|
@ -28,12 +28,10 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
||||
cost []*cfg.Gameatn // 技能升级消耗
|
||||
lvUpCount int32 // 技能升级的次数
|
||||
)
|
||||
code = this.StrengthenUpSkillCheck(session, req) // check
|
||||
if errdata != nil {
|
||||
if errdata = this.StrengthenUpSkillCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
_hero, code = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||
if errdata != nil {
|
||||
if _hero, errdata = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID); errdata != nil { // 查询目标卡是否存在
|
||||
return
|
||||
}
|
||||
// 查询配置表 找出原始品质
|
||||
@ -44,10 +42,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
for _, v := range heroCfg.Heroskillup {
|
||||
@ -61,7 +56,6 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
||||
}
|
||||
}
|
||||
// 消耗获取
|
||||
|
||||
atn := this.module.configure.GetHeroSkillCost(heroCfg.Star)
|
||||
for _, v := range atn {
|
||||
res := &cfg.Gameatn{
|
||||
@ -89,10 +83,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
sz = append(sz, skillData.Probability[skill.SkillLv])
|
||||
@ -100,7 +91,10 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
||||
}
|
||||
}
|
||||
if len(sz) == 0 {
|
||||
code = pb.ErrorCode_HeroMaxSkillLv
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroMaxSkillLv,
|
||||
Title: pb.ErrorCode_HeroMaxSkillLv.ToString(),
|
||||
}
|
||||
this.module.Errorf("技能升级失败:uid:%s,oid:%s", session.GetUserId(), _hero.Id)
|
||||
return
|
||||
}
|
||||
|
@ -26,45 +26,36 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
|
||||
_hero *pb.DBHero // 目标英雄
|
||||
err error
|
||||
)
|
||||
code = this.StrengthenUpStarCheck(session, req) // check
|
||||
if errdata != nil {
|
||||
if errdata = this.StrengthenUpStarCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
_hero, code = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID)
|
||||
if errdata != nil {
|
||||
if _hero, errdata = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 校验指定英雄
|
||||
starConf, err = this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star)
|
||||
if err != nil {
|
||||
if starConf, err = this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
heroConf, err := this.module.configure.GetHeroConfig(_hero.HeroID)
|
||||
if err != nil {
|
||||
if _, err = this.module.configure.GetHeroConfig(_hero.HeroID); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
nextHeroConfig, _ := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star+1)
|
||||
if nextHeroConfig == nil && heroConf.Type != comm.CardTypeStar {
|
||||
code = pb.ErrorCode_HeroMaxStarLv
|
||||
if nextHeroConfig == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroMaxStarLv,
|
||||
Title: pb.ErrorCode_HeroMaxStarLv.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package hero
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
@ -28,13 +29,11 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
_hero *pb.DBHero // 目标英雄
|
||||
cost []*cfg.Gameatn // 消耗的道具
|
||||
)
|
||||
code = this.StrengthenUplvCheck(session, req) // check
|
||||
if errdata != nil {
|
||||
if errdata = this.StrengthenUplvCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_hero, code = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID)
|
||||
if errdata != nil {
|
||||
if _hero, errdata = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID); errdata != nil {
|
||||
return
|
||||
}
|
||||
for k, v := range req.Item {
|
||||
@ -56,10 +55,6 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -74,22 +69,28 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
}
|
||||
|
||||
if addExp == 0 {
|
||||
code = pb.ErrorCode_HeroExpTypeErr
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroExpTypeErr,
|
||||
Title: pb.ErrorCode_HeroExpTypeErr.ToString(),
|
||||
Message: fmt.Sprintf("addExp:%d", addExp),
|
||||
}
|
||||
return
|
||||
}
|
||||
// 校验当前能不能升级
|
||||
if _hero.Lv >= this.module.configure.GetHeroMaxLv(_hero.Star) { // 达到最大等级
|
||||
code = pb.ErrorCode_HeroMaxLv
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroMaxLv,
|
||||
Title: pb.ErrorCode_HeroMaxLv.ToString(),
|
||||
Message: fmt.Sprintf("addExp:%d", addExp),
|
||||
}
|
||||
return
|
||||
}
|
||||
// 执行升级逻辑
|
||||
_, code = this.module.modelHero.AddCardExp(session, _hero, addExp, nil) // 加经验
|
||||
if errdata != nil {
|
||||
if _, errdata = this.module.modelHero.AddCardExp(session, _hero, addExp, nil); errdata != nil { // 加经验
|
||||
return
|
||||
}
|
||||
// 消耗金币
|
||||
if errdata = this.module.ConsumeRes(session, cost, true); errdata != nil { //道具扣除
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,11 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
}
|
||||
if req.ObjId != "" {
|
||||
if talent, err = this.module.modelTalent.GetHerotalentByObjId(session.GetUserId(), req.ObjId); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
this.module.Debugf("%v", talent)
|
||||
@ -73,21 +77,18 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
user := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
if user != nil {
|
||||
// 校验玩家等级
|
||||
if talentConf.Condition < user.Lv { // 等级不满足
|
||||
code = pb.ErrorCode_UserLvNoEnough
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserLvNoEnough,
|
||||
Title: pb.ErrorCode_UserLvNoEnough.ToString(),
|
||||
Message: fmt.Sprintf("等级不满足要求:curLv = %d,lv = %d", user.Lv, talentConf.Condition),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -98,13 +99,21 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
talent.Talent = make(map[int32]int32)
|
||||
}
|
||||
if _, ok := talent.Talent[req.TalentID]; ok {
|
||||
code = pb.ErrorCode_TalentRepeatLearn // 重复激活
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TalentRepeatLearn, // 重复激活
|
||||
Title: pb.ErrorCode_TalentRepeatLearn.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
for _, v := range talentConf.Before {
|
||||
if _, ok := talent.Talent[v]; !ok {
|
||||
code = pb.ErrorCode_TalentUnLockerBefore // 前置技能不满足
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TalentUnLockerBefore, // 前置技能不满足
|
||||
Title: pb.ErrorCode_TalentUnLockerBefore.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -124,7 +133,7 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
N: leftCount,
|
||||
}
|
||||
if errdata = this.module.CheckRes(session, []*cfg.Gameatn{fp}); errdata != nil {
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
|
||||
return
|
||||
}
|
||||
res = append(res, fp)
|
||||
|
@ -29,11 +29,17 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe
|
||||
|
||||
_talent, err1 := this.module.modelTalent.GetHerotalentByObjId(session.GetUserId(), req.ObjId) //根据对象id 获取数据
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_TalentErrData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TalentErrData,
|
||||
Title: pb.ErrorCode_TalentErrData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(_talent.Talent) == 0 { // 已经是重置状态
|
||||
code = pb.ErrorCode_TalentResetState
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TalentResetState,
|
||||
Title: pb.ErrorCode_TalentResetState.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -53,10 +59,6 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +510,10 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
|
||||
update map[string]interface{} // 属性变化
|
||||
)
|
||||
if hero == nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
update = make(map[string]interface{}, 0)
|
||||
|
@ -106,32 +106,44 @@ func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string,
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_HeroCreate
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroCreate,
|
||||
Title: pb.ErrorCode_HeroCreate.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 获取英雄
|
||||
func (this *Hero) GetHeroByObjID(uid, heroId string) (*pb.DBHero, pb.ErrorCode) {
|
||||
hero := this.modelHero.getOneHero(uid, heroId)
|
||||
if hero == nil {
|
||||
return nil, pb.ErrorCode_HeroNoExist
|
||||
func (this *Hero) GetHeroByObjID(uid, heroId string) (hero *pb.DBHero, errdata *pb.ErrorData) {
|
||||
hero = this.modelHero.getOneHero(uid, heroId)
|
||||
if hero != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
}
|
||||
return hero, pb.ErrorCode_Success
|
||||
return
|
||||
}
|
||||
|
||||
// 佩戴装备
|
||||
func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, equip []*pb.DB_Equipment) (errdata *pb.ErrorData) {
|
||||
|
||||
if hero == nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
list := make([]*pb.DBHero, 0)
|
||||
if newHero, err := this.modelHero.setEquipment(session.GetUserId(), hero); err != nil {
|
||||
code = pb.ErrorCode_HeroEquipUpdate
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroEquipUpdate,
|
||||
Title: pb.ErrorCode_HeroEquipUpdate.ToString(),
|
||||
}
|
||||
return
|
||||
} else {
|
||||
if newHero != nil {
|
||||
@ -214,7 +226,11 @@ func (this *Hero) CleanData(uid string) {
|
||||
// 创建一些特殊的英雄
|
||||
func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string, star, lv int32) (errdata *pb.ErrorData) {
|
||||
if session.GetUserId() == "" || heroConfId == "" || star == 0 || lv == 0 {
|
||||
return pb.ErrorCode_ReqParameterError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// 等级校验
|
||||
conf, _ := this.configure.GetHeroConfig(heroConfId)
|
||||
@ -248,7 +264,11 @@ func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string,
|
||||
}
|
||||
hero, err := this.modelHero.createSpecialHero(session.GetUserId(), heroConfId)
|
||||
if err != nil {
|
||||
return pb.ErrorCode_HeroCreate
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroCreate,
|
||||
Title: pb.ErrorCode_HeroCreate.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
hero.Lv = lv
|
||||
hero.Star = star
|
||||
@ -285,7 +305,7 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]
|
||||
if num == 0 { // 数量为0 不做处理
|
||||
continue
|
||||
}
|
||||
if hero, bFirst, atno, code = this.createRepeatHero(session, heroCfgId, num); errdata != nil {
|
||||
if hero, bFirst, atno, errdata = this.createRepeatHero(session, heroCfgId, num); errdata != nil {
|
||||
this.Errorf("create hero %s failed", heroCfgId)
|
||||
continue
|
||||
}
|
||||
@ -327,18 +347,18 @@ func (this *Hero) AddHeroExp(session comm.IUserSession, heroObjID string, exp in
|
||||
this.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
curAddExp, code = this.modelHero.AddCardExp(session, _hero, exp, model)
|
||||
curAddExp, errdata = this.modelHero.AddCardExp(session, _hero, exp, model)
|
||||
if errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_hero, code = this.GetHeroByObjID(session.GetUserId(), heroObjID)
|
||||
_hero, errdata = this.GetHeroByObjID(session.GetUserId(), heroObjID)
|
||||
if errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
curAddExp, code = this.modelHero.AddCardExp(session, _hero, exp, nil)
|
||||
curAddExp, errdata = this.modelHero.AddCardExp(session, _hero, exp, nil)
|
||||
if errdata != nil {
|
||||
return
|
||||
}
|
||||
@ -367,14 +387,18 @@ func (this *Hero) KungFuHero(session comm.IUserSession, heroObjID string, bKongf
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_hero, code = this.GetHeroByObjID(session.GetUserId(), heroObjID)
|
||||
_hero, errdata = this.GetHeroByObjID(session.GetUserId(), heroObjID)
|
||||
if errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if bKongfu && _hero.Status == pb.HeroType_HeroTypeKongFu {
|
||||
code = pb.ErrorCode_HeroAlreadyKongFuStatus // 已经是练功状态
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroAlreadyKongFuStatus, // 已经是练功状态
|
||||
Title: pb.ErrorCode_HeroAlreadyKongFuStatus.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -693,7 +717,11 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (errdata *pb.ErrorDat
|
||||
// 开始创建英雄
|
||||
hero, err := this.modelHero.createSpecialHero(session.GetUserId(), v.Hid)
|
||||
if err != nil {
|
||||
return pb.ErrorCode_HeroCreate
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroCreate,
|
||||
Title: pb.ErrorCode_HeroCreate.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
// 获取满级技能
|
||||
for _, skill := range hero.NormalSkill {
|
||||
@ -879,9 +907,9 @@ func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid []string
|
||||
}
|
||||
} else {
|
||||
for _, v := range heroOid {
|
||||
_hero, c := this.GetHeroByObjID(session.GetUserId(), v)
|
||||
if c != pb.ErrorCode_Success {
|
||||
code = c
|
||||
_hero, err := this.GetHeroByObjID(session.GetUserId(), v)
|
||||
if err != nil {
|
||||
errdata = err
|
||||
return
|
||||
}
|
||||
_szHero = append(_szHero, _hero)
|
||||
@ -895,14 +923,20 @@ func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid []string
|
||||
} else if v.Fulllvenr == 0 && fulllvenr != 0 {
|
||||
// 校验有没有满级
|
||||
if v.Lv < this.configure.GetHeroMaxLv(v.Star) {
|
||||
code = pb.ErrorCode_HeroLvNoEnough // 必须满级
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroLvNoEnough,
|
||||
Title: pb.ErrorCode_HeroLvNoEnough.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
v.Fulllvenr = fulllvenr
|
||||
_heroMap["fulllvenr"] = v.Fulllvenr
|
||||
|
||||
} else {
|
||||
code = pb.ErrorCode_HeroIsRegister
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroIsRegister,
|
||||
Title: pb.ErrorCode_HeroIsRegister.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if this.IsCross() {
|
||||
|
Loading…
Reference in New Issue
Block a user