From 6b534adc07bf6fbcccf984a2c200201ac4470464 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Wed, 10 Dec 2025 18:37:32 +0000 Subject: [PATCH] =?UTF-8?q?```=20feat(fight):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=88=98=E6=96=97=E5=9B=9E=E5=90=88Hook=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E5=AE=9E=E7=8E=B0=E7=89=B9=E5=AE=9A=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E4=B8=8B=E5=BC=BA=E5=88=B6=E7=BB=93=E6=9D=9F=E6=88=98=E6=96=97?= =?UTF-8?q?=E5=92=8C=E9=9A=8F=E6=9C=BA=E5=87=BA=E6=89=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/common/fight.go | 3 ++- logic/service/fight/boss/NewSeIdx_13.go | 13 +++++++++++++ logic/service/fight/boss/NewSeIdx_23.go | 5 ++--- logic/service/fight/fightc.go | 14 ++++++++++++++ logic/service/fight/input.go | 6 +++++- logic/service/fight/input/fight.go | 8 ++++++++ logic/service/fight/input/interface.go | 3 ++- logic/service/fight/loop.go | 5 ++++- logic/service/fight/node/fight.go | 4 ++++ 9 files changed, 54 insertions(+), 7 deletions(-) diff --git a/logic/service/common/fight.go b/logic/service/common/fight.go index 473bdc5f0..13675da7e 100644 --- a/logic/service/common/fight.go +++ b/logic/service/common/fight.go @@ -9,12 +9,13 @@ type FightI interface { Over(c PlayerI, id info.EnumBattleOverReason) //逃跑 UseSkill(c PlayerI, id uint32) //使用技能 GetCurrPET(c PlayerI) *info.BattlePetEntity //当前精灵 - + GetOverInfo() info.FightOverInfo Ownerid() uint32 ReadyFight(c PlayerI) //是否准备战斗 ChangePet(c PlayerI, id uint32) Capture(c PlayerI, id uint32) GetRand() *rand.Rand + LoadPercent(c PlayerI, percent int32) UseItem(c PlayerI, cacthid, itemid uint32) Chat(c PlayerI, msg string) diff --git a/logic/service/fight/boss/NewSeIdx_13.go b/logic/service/fight/boss/NewSeIdx_13.go index 65b54af1c..fd5d4ec77 100644 --- a/logic/service/fight/boss/NewSeIdx_13.go +++ b/logic/service/fight/boss/NewSeIdx_13.go @@ -1,6 +1,7 @@ package effect import ( + "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" ) @@ -10,6 +11,18 @@ type NewSel13 struct { NewSel0 } +func (e *NewSel13) HookAction() bool { + if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime { + return true + } + r := e.Ctx().Our.FightC.GetOverInfo() + if r.Round == uint32(e.Args()[0].IntPart()) { + e.Ctx().Our.FightC.Over(e.Ctx().Our.Player, info.BattleOverReason.PlayerEscape) + return false //阻止技能释放 + } + + return true //阻止技能释放 +} func init() { input.InitEffect(input.EffectType.NewSel, 13, &NewSel13{}) } diff --git a/logic/service/fight/boss/NewSeIdx_23.go b/logic/service/fight/boss/NewSeIdx_23.go index 280d10d52..57d2a9c88 100644 --- a/logic/service/fight/boss/NewSeIdx_23.go +++ b/logic/service/fight/boss/NewSeIdx_23.go @@ -9,8 +9,7 @@ import ( "github.com/alpacahq/alpacadecimal" ) -// 23. 自身体力降到N以下时, 每次(针对多宠)攻击必定秒杀对方, 且必定先手;(a1: high 16, a2: low 16) -// TODO: 实现自身体力降到N以下时, 每次(针对多宠)攻击必定秒杀对方, 且必定先手;(a1: high 16, a2: low 16)的核心逻辑 +// 23. 自身体力降到N以下时, 每次(针对多宠)攻击必定秒杀对方, 且必定先手; type NewSel23 struct { NewSel0 } @@ -44,7 +43,7 @@ func (e *NewSel23) Compare_Pre(fattack *action.SelectSkillAction, sattack *actio } func (e *NewSel23) OnSkill() bool { - //full32 := int(e.Args()[0])<<16 | int(e.Args()[1]) + if int(e.Ctx().Our.CurrentPet.GetHP().Cmp(e.Args()[0])) == -1 { e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{ diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 0aea66b4c..0f3e386fa 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -13,6 +13,7 @@ import ( "github.com/alpacahq/alpacadecimal" "github.com/barkimedes/go-deepcopy" + "github.com/gogf/gf/v2/util/grand" ) // 处理技能攻击逻辑 @@ -195,9 +196,22 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { fattack, sattack = sattack, fattack //互换先手权 f.First, f.Second = f.Second, f.First } + if f.Second.GetProp(4, false) == f.First.GetProp(4, false) { + + if grand.Meet(1, 2) { //随机出手 + fattack, sattack = sattack, fattack //互换先手权 + f.First, f.Second = f.Second, f.First + } + + } } } + + if fattack == nil && sattack == nil { + fattack, sattack = sattack, fattack //互换先手权 + f.First, f.Second = f.Second, f.First + } var attacker, defender *input.Input //开始回合操作 diff --git a/logic/service/fight/input.go b/logic/service/fight/input.go index e4f78b701..ab3e3bac3 100644 --- a/logic/service/fight/input.go +++ b/logic/service/fight/input.go @@ -37,7 +37,7 @@ type FightC struct { rand *rand.Rand StartTime time.Time actionChan chan action.BattleActionI // 所有操作统一从这里进入 - Round int //回合数 + quit chan struct{} over chan struct{} First *input.Input @@ -355,3 +355,7 @@ func (f *FightC) GetOverChan() chan struct{} { return f.over } +func (f *FightC) GetOverInfo() info.FightOverInfo { + return f.FightOverInfo + +} diff --git a/logic/service/fight/input/fight.go b/logic/service/fight/input/fight.go index 872e1ac9e..d7ce857b6 100644 --- a/logic/service/fight/input/fight.go +++ b/logic/service/fight/input/fight.go @@ -190,6 +190,14 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) { } func (our *Input) GetAction(opp *Input) { + + next := our.Exec(func(t Effect) bool { + + return t.HookAction() + }) + if !next { + return + } // 获取己方当前宠物和对方当前宠物 selfPet := our.FightC.GetCurrPET(our.Player) //没血就切换精灵 diff --git a/logic/service/fight/input/interface.go b/logic/service/fight/input/interface.go index c4d552458..143594b0b 100644 --- a/logic/service/fight/input/interface.go +++ b/logic/service/fight/input/interface.go @@ -45,7 +45,8 @@ type Effect interface { // OnOwnerSwitchIn() bool // 所属玩家精灵出战时触发 // OnOwnerSwitchOut() bool // 所属玩家精灵下场时触发 - Turn_End() //回合结束计算 + Turn_End() //回合结束计算 + HookAction() bool //出手前的hook参数,返回false阻止继续出手 //PreBattleEnd() bool //战斗结束前 OnBattleEnd() bool //战斗结束 Prop_Befer(in *Input, prop, level int8, ptype info.EnumAbilityOpType) bool //锁定属性 diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index 970318a6b..bd3a1009e 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -207,7 +207,10 @@ func (f *FightC) handleTimeout(ourID, oppID uint32, actions map[uint32]action.Ba f.Reason = info.BattleOverReason.PlayerOVerTime f.closefight = true //对方赢 - f.WinnerId = f.GetInputByPlayer(f.getPlayerByID(pid), true).Player.GetInfo().UserID + if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC { + f.WinnerId = f.GetInputByPlayer(f.getPlayerByID(pid), true).Player.GetInfo().UserID + + } } } diff --git a/logic/service/fight/node/fight.go b/logic/service/fight/node/fight.go index dcca4e952..42cf77f0a 100644 --- a/logic/service/fight/node/fight.go +++ b/logic/service/fight/node/fight.go @@ -26,3 +26,7 @@ func (e *EffectNode) Action_end() bool { // panic("not implemented") // TODO: Implement return true } +func (e *EffectNode) HookAction() bool { + // panic("not implemented") // TODO: Implement + return true +} \ No newline at end of file