feat(fight): 优化战斗逻辑与精灵切换流程
- 在多个战斗控制器方法中添加 defer 调用,确保战斗操作正确延迟执行 - 修改 ChangePet 方法返回值类型,增强接口一致性 - 修复战斗准备阶段逻辑,重构战斗开始信息构建过程 - 移除冗余广播调用,调整 PVE 战斗初始化流程 - 更新 README 中的 pprof 命令地址并完善项目介绍部分 fix(effect): 修复效果叠加逻辑与ID解析问题 - 效果叠加时默认增加一层,而非直接相加参数 - 修正 EffectIDCombiner 类型、CatchTime 的掩码偏移计算错误 - 添加重复效果日志输出,便于调试追踪 feat(boss): 完善BOSS特性实现逻辑 - 修正 NewSel17 特性
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/player"
|
||||
"context"
|
||||
"log"
|
||||
|
||||
@@ -60,15 +59,17 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
|
||||
cool.Loger.Debug(context.Background(), " 战斗chan已关闭")
|
||||
return
|
||||
}
|
||||
|
||||
selfinput := f.GetInputByPlayer(c, false)
|
||||
InitAttackValue := *selfinput.AttackValue
|
||||
oldpet := selfinput.CurrentPet
|
||||
//todo 待实现无法切精灵的情况
|
||||
ret := &action.ActiveSwitchAction{
|
||||
BaseAction: action.NewBaseAction(c.GetInfo().UserID),
|
||||
}
|
||||
selfinput.CurrentPet, ret.Reason = selfinput.GetPet(id)
|
||||
|
||||
selfinput := f.GetInputByPlayer(c, false)
|
||||
|
||||
selfinput.CurrentPet, ret.Reason = selfinput.GetPet(id)
|
||||
c.SendPackCmd(2407, &ret.Reason)
|
||||
InitAttackValue := *selfinput.AttackValue
|
||||
oldpet := selfinput.CurrentPet
|
||||
f.Switch = append(f.Switch, ret)
|
||||
selfinput.InitAttackValue() //切换精灵消除能力提升
|
||||
//这时候精灵已经切换过了,可以直接给新精灵加效果
|
||||
@@ -83,13 +84,6 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
|
||||
})
|
||||
})
|
||||
|
||||
f.Broadcast(func(ff *input.Input) { //先给自身广播
|
||||
if ff.Player.GetInfo().UserID == c.GetInfo().UserID {
|
||||
ff.Player.SendPackCmd(2407, &ret.Reason)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
f.actionChan <- ret
|
||||
}
|
||||
|
||||
@@ -135,31 +129,12 @@ func (f *FightC) UseItem(c common.PlayerI, cacthid, itemid uint32) {
|
||||
|
||||
// ReadyFight 处理玩家战斗准备逻辑,当满足条件时启动战斗循环
|
||||
func (f *FightC) ReadyFight(c common.PlayerI) {
|
||||
// 1. 构建战斗开始信息(整理双方初始宠物信息)
|
||||
fightStartInfo := f.buildFightStartInfo()
|
||||
|
||||
// 2. 标记当前玩家已准备完成
|
||||
input := f.GetInputByPlayer(c, false)
|
||||
input.Finished = true
|
||||
|
||||
// 3. 根据战斗类型判断是否满足战斗启动条件,满足则启动
|
||||
switch f.Info.Status {
|
||||
|
||||
case info.BattleMode.FIGHT_WITH_NPC: // NPC/野怪战斗:处理捕捉相关逻辑后启动
|
||||
//f.handleNPCFightSpecial(&fightStartInfo)
|
||||
|
||||
if f.Opp.Player.(*player.AI_player).CanCapture > 0 {
|
||||
f.Opp.CanCapture = f.Opp.Player.(*player.AI_player).CanCapture
|
||||
fightStartInfo.Info2.Catchable = 1 //可以捕捉就置1
|
||||
}
|
||||
f.Opp.AttackValue.Prop = f.Opp.Player.(*player.AI_player).Prop
|
||||
fightStartInfo.Info2.Prop = f.Opp.AttackValue.Prop
|
||||
f.startBattle(fightStartInfo)
|
||||
default: // PVP战斗:需双方都准备完成
|
||||
if f.checkBothPlayersReady(c) {
|
||||
f.startBattle(fightStartInfo)
|
||||
}
|
||||
|
||||
if f.checkBothPlayersReady(c) {
|
||||
f.startBattle(f.FightStartOutboundInfo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,12 +173,6 @@ func (f *FightC) startBattle(startInfo info.FightStartOutboundInfo) {
|
||||
log.Panic(context.Background(), "战斗循环提交失败", "error", err)
|
||||
}
|
||||
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
|
||||
ff.InitEFFect(&startInfo)
|
||||
|
||||
})
|
||||
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
|
||||
// 通知双方玩家准备完成,即将开始战斗
|
||||
|
||||
Reference in New Issue
Block a user