refactor(fight): 重构战斗系统

- 优化了战斗逻辑和数据结构
- 修复了一些战斗相关的错误
- 提高了代码的可读性和可维护性
This commit is contained in:
2025-09-06 00:31:08 +08:00
parent f81593bfaf
commit ca8c4bcd04
18 changed files with 176 additions and 157 deletions

View File

@@ -31,7 +31,10 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn
ttt.OpponentInfo = info.FightUserInfo{UserID: 0}
refpet := c.OgreInfo.Data[data.Number]
if refpet.Id == 0 {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
mo := model.GenPetInfo(
int(refpet.Id), []int{0, 31},
[]int{0, 24},
@@ -46,11 +49,12 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn
}
if c.FightC != nil {
return nil, -1
return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight
}
c.FightC = &service.FightC{}
c.FightC.NewFight(&ttt, c) //把两个玩家都传进去
c.FightC.NewFight(&ttt, c, mo) //把两个玩家都传进去
c.FightC.OwnerID = c.Info.UserID
return nil, -1
}
@@ -69,7 +73,7 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou
// 使用技能包
func (h Controller) UseSkill(data *fight.UseSkillInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.FightC.UseSkill(c, data.SkillId)
c.FightC.UseSkill(c, int32(data.SkillId))
return nil, 0
}