英雄接口扩展

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)
CreateOneHero(session IUserSession, heroCfgId string, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData)
}
//玩家

View File

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