diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index e842c6ddb..9c4fe24c9 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -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 数据 diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index f56c55922..1ab2c9143 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -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