feat(pet): 优化精灵生成逻辑,支持随机个体与特性配置

- 修改 `GenPetInfo` 函数参数类型,从数组改为单个整数,简化调用方式
- 支持传入 -1 表示随机生成个体值、性格等属性
- 统一战斗野怪和任务精灵的生成逻辑,确保一致性
- 添加注释说明参数含义,提升代码可读性
- 修复野怪无特性时的处理逻辑,避免空数组引发问题
This commit is contained in:
2025-09-20 13:12:45 +08:00
parent 85ccf751de
commit 892f9207df
3 changed files with 52 additions and 23 deletions

View File

@@ -26,11 +26,11 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla
}
mo = model.GenPetInfo(
int(petid), []int{0, 31},
[]int{0, 24},
[]int{0}, //野怪没特性
[]int{int(0)},
[]int{int(2)})
int(petid), 24, //24个体
-1,
0, //野怪没特性
0,
2)
}
if c.FightC != nil {
@@ -41,6 +41,8 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla
return nil, -1
}
// 战斗野怪
func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
refpet := c.OgreInfo.Data[data.Number]
@@ -49,11 +51,11 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
mo := model.GenPetInfo(
int(refpet.Id), []int{0, 31},
[]int{0, 24},
[]int{0}, //野怪没特性
[]int{int(refpet.Shiny)},
[]int{int(refpet.Lv)})
int(refpet.Id), -1,
-1,
0, //野怪没特性
int(refpet.Shiny),
int(refpet.Lv))
if c.FightC != nil {
return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight

View File

@@ -102,7 +102,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player.
case 3:
petid = 4
}
r := model.GenPetInfo(petid, []int{0, 31}, []int{0, 24}, []int{0, 39}, []int{0}, []int{5})
r := model.GenPetInfo(petid, 31, -1, 0, 0, 5)
result.CaptureTime = r.CatchTime
result.PetTypeId = r.ID
c.Service.PetAdd(*r)