refactor: 统一战斗报文发送逻辑
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-04-08 12:26:37 +08:00
committed by cnb
parent 4b89588c22
commit ca96be3905
7 changed files with 210 additions and 363 deletions

View File

@@ -174,11 +174,7 @@ func (f *FightC) battleLoop() {
//大乱斗,给个延迟
//<-time.After(1000)
f.Broadcast(func(ff *input.Input) {
if f.LegacyGroupProtocol {
f.sendLegacyGroupOver(ff.Player, &f.FightOverInfo)
} else {
ff.Player.SendPackCmd(2506, &f.FightOverInfo)
}
f.sendFightPacket(ff.Player, fightPacketOver, &f.FightOverInfo)
ff.Player.QuitFight()
@@ -264,7 +260,7 @@ func (f *FightC) collectPlayerActions(expectedSlots map[actionSlotKey]struct{})
ret.Reason = reason
ret.Reason.ActorIndex = uint32(ret.ActorIndex)
selfinput.Player.SendPackCmd(2407, &ret.Reason)
f.sendFightPacket(selfinput.Player, fightPacketChangePetSuccess, &ret.Reason)
f.Switch[key] = ret
@@ -285,7 +281,7 @@ func (f *FightC) collectPlayerActions(expectedSlots map[actionSlotKey]struct{})
selfinput.CanChange = 0
if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC && paction.GetPlayerID() == 0 {
f.Switch = make(map[actionSlotKey]*action.ActiveSwitchAction)
f.Our[0].Player.SendPackCmd(2407, &ret.Reason)
f.sendFightPacket(f.Our[0].Player, fightPacketChangePetSuccess, &ret.Reason)
//println("AI出手死切")
f.triggerNPCActions() // boss出手后获取出招
@@ -606,7 +602,7 @@ func (f *FightC) handleItemAction(a *action.UseItemAction) {
if currentPet == nil {
return
}
ff.Player.SendPackCmd(2406, &info.UsePetIteminfo{
f.sendFightPacket(ff.Player, fightPacketUseItem, &info.UsePetIteminfo{
UserID: source.UserID,
ChangeHp: int32(addhp),
ItemID: uint32(item.ID),
@@ -621,7 +617,7 @@ func (f *FightC) handleItemAction(a *action.UseItemAction) {
if currentPet == nil {
return
}
ff.Player.SendPackCmd(2406, &info.UsePetIteminfo{
f.sendFightPacket(ff.Player, fightPacketUseItem, &info.UsePetIteminfo{
UserID: source.UserID,
ItemID: uint32(item.ID),