英雄接口扩展

This commit is contained in:
meixiongfeng 2023-08-29 10:43:15 +08:00
parent f64ffa6b30
commit 74c239a721
3 changed files with 86 additions and 40 deletions

View File

@ -155,6 +155,8 @@ type (
// 检查圣桃树奖励是否发放 // 检查圣桃树奖励是否发放
CheckPeachReward(session IUserSession, ctime int64) CheckPeachReward(session IUserSession, ctime int64)
CreateOneHero(session IUserSession, heroCfgId string, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData)
} }
//玩家 //玩家

View File

@ -21,25 +21,25 @@ func (this *apiComp) DrawCardCheck(session comm.IUserSession, req *pb.HeroDrawCa
//抽卡 //抽卡
func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq) (errdata *pb.ErrorData) { func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq) (errdata *pb.ErrorData) {
var ( var (
szCards []string // 最终抽到的卡牌 szCards []string // 最终抽到的卡牌
drawCount int32 // 抽卡次数 drawCount int32 // 抽卡次数
szStar []int32 //星级 szStar []int32 //星级
costRes []*cfg.Gameatn // 消耗 costRes []*cfg.Gameatn // 消耗
star4Count int32 // 10连抽4星数量 star4Count int32 // 10连抽4星数量
star5Count int32 // 10连抽5星数量 star5Count int32 // 10连抽5星数量
cfgGlobal *cfg.GameGlobalData // 全局配置 cfgGlobal *cfg.GameGlobalData // 全局配置
heroRecord *pb.DBHeroRecord heroRecord *pb.DBHeroRecord
atno []*pb.UserAtno // 最终获得的资源 strPool []string // 10连跨多个卡池情况
strPool []string // 10连跨多个卡池情况 update map[string]interface{}
update map[string]interface{} normalDraw bool // 是否是普通抽
normalDraw bool // 是否是普通抽 drawConf *cfg.GameDrawPoolData
drawConf *cfg.GameDrawPoolData err error
err error atno []*pb.UserAtno
IsBaodiPool bool // 是否是保底卡池 IsBaodiPool bool // 是否是保底卡池
appointmap map[int32]string // 指定次数抽卡到指定卡池 appointmap map[int32]string // 指定次数抽卡到指定卡池
// 首次获得英雄 // 首次获得英雄
firstGet map[string]bool firstGet map[string]bool
reward []*cfg.Gameatn // 许愿石奖励
) )
update = make(map[string]interface{}) update = make(map[string]interface{})
appointmap = make(map[int32]string) appointmap = make(map[int32]string)
@ -110,22 +110,22 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
} }
return return
} }
if errdata, atno = this.module.DispenseAtno(session, []*cfg.Gameatn{{ var hero *pb.DBHero
A: "hero", firstGet[heroRecord.WishHero] = false
T: heroRecord.WishHero,
N: 1, if hero, atno, errdata = this.module.ModuleHero.CreateOneHero(session, heroRecord.WishHero, true); errdata == nil {
}}, true); errdata == nil {
firstGet[heroRecord.WishHero] = true
rsp.Data = append(rsp.Data, &pb.AtnoData{Atno: atno})
for _, v := range atno { for _, v := range atno {
if v.A == "hero" && v.N == 1 { if v.A == "hero" && v.T == heroRecord.WishHero && v.N == 1 {
firstGet[heroRecord.WishHero] = true
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { // 广播 首次获得英雄 if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { // 广播 首次获得英雄
this.chat.SendSysChatToWorld(comm.ChatSystem13, nil, 0, 0, user.Name, v.T) if HeroConf, err := this.module.configure.GetHeroConfig(heroRecord.WishHero); err == nil {
this.chat.SendSysChatToWorld(comm.ChatSystem13, hero, HeroConf.Star, 0, user.Name, v.T)
}
} }
} else if v.A == "hero" && v.N == 0 {
firstGet[v.T] = false
} }
} }
rsp.Data = append(rsp.Data, &pb.AtnoData{Atno: atno})
} else { } else {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError, Code: pb.ErrorCode_ReqParameterError,
@ -320,14 +320,18 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
update["baodi5"] = heroRecord.Baodi5 update["baodi5"] = heroRecord.Baodi5
for _, heroId := range szCards { for _, heroId := range szCards {
var reward []*cfg.Gameatn //var
if c, err := this.module.configure.GetHeroConfig(heroId); err == nil { var (
szStar = append(szStar, c.Star) // 获得许愿石 hero *pb.DBHero
HeroConf *cfg.GameHeroData
)
if HeroConf, err = this.module.configure.GetHeroConfig(heroId); err == nil {
szStar = append(szStar, HeroConf.Star) // 获得许愿石
var tmp *cfg.Gameatn var tmp *cfg.Gameatn
if c.Star == 4 { if HeroConf.Star == 4 {
tmp = this.module.ModuleTools.GetGlobalConf().RewardStar4 tmp = this.module.ModuleTools.GetGlobalConf().RewardStar4
reward = append(reward, tmp) reward = append(reward, tmp)
} else if c.Star == 5 { } else if HeroConf.Star == 5 {
tmp = this.module.ModuleTools.GetGlobalConf().RewardStar5 tmp = this.module.ModuleTools.GetGlobalConf().RewardStar5
reward = append(reward, tmp) reward = append(reward, tmp)
@ -353,22 +357,27 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
} }
} }
} }
reward = append(reward, &cfg.Gameatn{
A: "hero", firstGet[heroId] = false
T: heroId,
N: 1,
})
firstGet[heroId] = true
var atno []*pb.UserAtno var atno []*pb.UserAtno
if errdata, atno = this.module.DispenseAtno(session, reward, true); errdata == nil { if hero, atno, errdata = this.module.ModuleHero.CreateOneHero(session, heroId, true); errdata == nil {
for _, v := range atno { for _, v := range atno {
if v.A == "hero" && v.T == heroId && v.N == 0 { if v.A == "hero" && v.T == heroId && v.N == 1 {
firstGet[heroId] = false firstGet[heroId] = true
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { // 广播 首次获得英雄
this.chat.SendSysChatToWorld(comm.ChatSystem13, hero, HeroConf.Star, 0, user.Name, v.T)
}
} }
} }
rsp.Data = append(rsp.Data, &pb.AtnoData{Atno: atno}) rsp.Data = append(rsp.Data, &pb.AtnoData{Atno: atno})
} }
}
// 发放许愿石奖励
if errdata, _ = this.module.DispenseAtno(session, reward, true); errdata != nil {
return
} }
rsp.FirstGet = firstGet rsp.FirstGet = firstGet
this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update) this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update)

View File

@ -1090,3 +1090,38 @@ func (this *Hero) AddHerosExp(session comm.IUserSession, heroObjs []string, exp
session.SendMsg(string(this.GetType()), "change", &pb.HeroChangePush{List: _changeHero}) session.SendMsg(string(this.GetType()), "change", &pb.HeroChangePush{List: _changeHero})
return return
} }
// 获得一个英雄
func (this *Hero) CreateOneHero(session comm.IUserSession, heroCfgId string, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData) {
var (
//hero *pb.DBHero
firstGet []string
bFirst bool
szAddHero []string
)
if hero, bFirst, atno, errdata = this.createRepeatHero(session, heroCfgId, 1); errdata != nil {
this.Errorf("create hero %s failed", heroCfgId)
return
}
szAddHero = append(szAddHero, heroCfgId)
if bFirst {
firstGet = append(firstGet, heroCfgId)
}
if db.IsCross() {
this.moduleFetter.SendRpcAddHero(session.GetUserId(), szAddHero, session.GetServiecTag())
} else {
this.moduleFetter.AddHerosFetterData(session.GetUserId(), szAddHero)
}
if bPush { //推送
session.SendMsg("hero", "change", &pb.HeroChangePush{List: []*pb.DBHero{hero}})
// 首次获得英雄 则推送
if len(firstGet) > 0 {
session.SendMsg("hero", "firstget", &pb.HeroFirstGetPush{
HeroId: firstGet,
})
}
}
return
}