```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(boss-fight): 添加boss id验证并修复捕捉机制

- 在玩家挑战boss时添加boss ids
This commit is contained in:
昔念
2026-02-26 00:05:43 +08:00
parent f7e5880092
commit dee5278f52
2 changed files with 18 additions and 4 deletions

View File

@@ -34,6 +34,9 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
if len(mdata.BossIds) == 0 {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
bosinfo := service.NewBossService().Get(mdata.BossIds[0])
if bosinfo == nil {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
@@ -85,9 +88,13 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play
ai := player.NewAI_player(monsterInfo)
ai.CanCapture = bosinfo[0].IsCapture
if xmlres.PetMAP[int(monster.ID)].CatchRate == 0 {
ai.CanCapture = 0
if bosinfo[0].IsCapture != 0 {
ai.CanCapture = xmlres.PetMAP[int(monster.ID)].CatchRate
if xmlres.PetMAP[int(monster.ID)].CatchRate == 0 {
ai.CanCapture = 0
}
}
ai.Prop[0] = 2
fight.NewFight(p, ai, func(foi info.FightOverInfo) {
if mdata.WinBonusID != 0 {

View File

@@ -66,10 +66,17 @@ func (p *Player) GenMonster() {
if p.Data[i].ID != 0 {
p.Data[i].Lv = uint32(grand.N(v.MinLevel, v.MaxLevel))
p.Data[i].IsCapture = v.IsCapture //实现捕捉限制
if handleNPCFightSpecial(p.Data[i].ID) == 0 {
if v.IsCapture != 0 {
if handleNPCFightSpecial(p.Data[i].ID) == 0 {
p.Data[i].IsCapture = 0
} else {
p.Data[i].IsCapture = handleNPCFightSpecial(p.Data[i].ID) //施加捕捉率
}
} else {
p.Data[i].IsCapture = 0
}
if len(v.RefreshID) == 1 { //说明这里只固定刷一个,概率变尼尔尼奥,不是稀有精灵
nieo, _, _ := p.Roll(1, 25)