feat: 增强踢人逻辑与BOSS脚本支持
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

优化踢人超时处理和僵尸连接清理,支持BOSS动作脚本并增加测试,修复事件匹配与战斗循环中的并发问题。
This commit is contained in:
xinian
2026-04-05 21:59:22 +08:00
committed by cnb
parent 36dd93b076
commit c021b40fbe
16 changed files with 457 additions and 151 deletions

View File

@@ -110,7 +110,7 @@ func (h Controller) PetTawor(data *StartTwarInboundInfo, c *player.Player) (resu
result = &fight.S2C_ChoiceLevelRequestInfo{CurFightLevel: currentLevel}
appendTowerNextBossPreview(&result.BossID, bossList)
monsterInfo, ok := buildTowerMonsterInfo(currentBoss)
monsterInfo, bossScript, ok := buildTowerMonsterInfo(currentBoss)
if !ok {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
@@ -119,6 +119,7 @@ func (h Controller) PetTawor(data *StartTwarInboundInfo, c *player.Player) (resu
c.Fightinfo.Status = fightinfo.BattleMode.FIGHT_WITH_NPC
ai := player.NewAI_player(monsterInfo)
ai.BossScript = bossScript
_, err = fight.NewFight(c, ai, c.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
if foi.Reason != 0 || foi.WinnerId != c.Info.UserID {
return
@@ -195,10 +196,10 @@ func appendTowerNextBossPreview(dst *[]uint32, bossList []configmodel.BaseTowerC
}
}
func buildTowerMonsterInfo(towerBoss configmodel.BaseTowerConfig) (*model.PlayerInfo, bool) {
func buildTowerMonsterInfo(towerBoss configmodel.BaseTowerConfig) (*model.PlayerInfo, string, bool) {
bosses := service.NewBossService().Get(towerBoss.BossIds[0])
if len(bosses) == 0 {
return nil, false
return nil, "", false
}
monsterInfo := &model.PlayerInfo{Nick: towerBoss.Name}
@@ -234,7 +235,7 @@ func buildTowerMonsterInfo(towerBoss configmodel.BaseTowerConfig) (*model.Player
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
}
return monsterInfo, true
return monsterInfo, bosses[0].Script, true
}
func handleTowerFightWin(c *player.Player, cmd uint32, taskID int, currentLevel uint32) {