75 lines
2.0 KiB
Go
75 lines
2.0 KiB
Go
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
|
||
}
|