#31123 任务 【梦工场系统】 【招募】兑换功能拓展

This commit is contained in:
meixiongfeng 2023-08-15 10:29:28 +08:00
parent 8a228f008a
commit fbf8accb59
2 changed files with 34 additions and 17 deletions

View File

@ -65,28 +65,39 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
}
// 校验是否是心愿招募
if req.DrawType == comm.DrawCardType6 && req.DrawCount == 1 {
atn := this.module.ModuleTools.GetGlobalConf().ExchangeHero // 校验消耗数量
if errdata = this.module.CheckRes(session, []*cfg.Gameatn{atn}); errdata != nil {
return
}
// 心愿消耗 走单独配置
// 校验许愿英雄
var cd int64
var drcount int32
if heroRecord.WishHero == "" { // 如果当前许愿英雄是空 则读取 默认许愿英雄
if conf := this.module.configure.GetWishHeroReplaceConfig(); conf != nil {
//atn := this.module.ModuleTools.GetGlobalConf().ExchangeHero // 校验消耗数量
if conf := this.module.configure.GetWishHeroReplaceConfig(); conf != nil {
if heroRecord.WishHero == "" { // 如果当前许愿英雄是空 则读取 默认许愿英雄
heroRecord.WishHero = conf.InitHero
cd = int64(conf.Cond[heroRecord.WishHero].cd)
drcount = conf.Cond[heroRecord.WishHero].num
}
}
// 校验该抽卡是否在CD 中
if outTime, ok := heroRecord.Wish[heroRecord.WishHero]; ok {
if outTime < configure.Now().Unix() {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroDrawCD,
// 校验该抽卡是否在CD 中
if outTime, ok := heroRecord.Wish[heroRecord.WishHero]; ok {
if outTime < configure.Now().Unix() {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroDrawCD,
}
return
}
}
costRes = append(costRes, conf.Cond[heroRecord.WishHero].buyCos)
if errdata = this.module.CheckRes(session, costRes); errdata != nil {
return
}
} else { // 配置错误
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: fmt.Sprintf("GetWishHeroReplaceConfig is nil"),
}
return
}
// 校验 解锁所需抽奖次数
if drcount > heroRecord.Race[comm.DrawCardType0] {
@ -109,10 +120,14 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
}
}
} else {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
return
}
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{atn}, true); errdata != nil {
if errdata = this.module.ConsumeRes(session, costRes, true); errdata != nil {
return
}
// 修改recode 数据

View File

@ -44,8 +44,9 @@ const (
)
type CondData struct {
cd int32
num int32
cd int32
num int32
buyCos *cfg.Gameatn
}
type Replace struct {
InitHero string // 默认英雄
@ -176,8 +177,9 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
if v.Pool == 1 {
this.appoint.InitHero = v.HeroInitial
this.appoint.Cond[v.HeroReplace] = &CondData{
cd: v.ReplaceCd,
num: v.ReplaceNum,
cd: v.ReplaceCd,
num: v.ReplaceNum,
buyCos: v.BuyCos,
}
} else if v.Pool == 2 {
this.wish.InitHero = v.HeroInitial