go_dreamfactory/modules/hero/api_heroSkillUp.go
2022-06-28 20:15:51 +08:00

75 lines
2.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
)
//参数校验
func (this *apiComp) StrengthenUpSkillCheck(session comm.IUserSession, req *pb.HeroStrengthenUpSkillReq) (result map[string]interface{}, code comm.ErrorCode) {
if req.HeroObjID == "" || req.CostCardObj == "" {
code.Code = pb.ErrorCode_ReqParameterError
return
}
var (
tagColor int32
costColor int32
)
_hero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist
return
}
_costHero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.CostCardObj) // 查询消耗卡是否存在
if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist
return
}
// 查询配置表 找出原始品质
tmp := this.moduleHero.configure.GetHero(_hero.HeroID)
if tmp == nil {
code.Code = pb.ErrorCode_HeroNoExist
return
}
tagColor = tmp.Color
tmp = this.moduleHero.configure.GetHero(_costHero.HeroID)
if tmp == nil {
code.Code = pb.ErrorCode_HeroNoExist
return
}
costColor = tmp.Color
if costColor != tagColor {
code.Code = pb.ErrorCode_HeroColorErr
return
}
result = map[string]interface{}{
"heroid": _hero.HeroID,
}
return
}
/// 英雄技能升级
func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroStrengthenUpSkillReq) (code pb.ErrorCode) {
defer func() {
if code == pb.ErrorCode_Success {
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroStrengthenUpSkillResp{})
}
}()
var (
tagHero int32 // 操作的英雄configid
)
tagHero = agrs["heroid"].(int32)
log.Debugf("英雄:%d 技能升级", tagHero)
config, err := this.moduleHero.configure.GetHeroSkillUpConfig()
if err != nil {
return
}
// 先随机一个没有升满
for _, value := range config.GetDataList() {
log.Debugf("%d", value.Hid)
}
return
}