From 6cb091a4be8d010b820283e3b1eed3161f7910b1 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Mon, 10 Nov 2025 08:25:40 +0000 Subject: [PATCH] =?UTF-8?q?fix(fight):=20=E5=A2=9E=E5=8A=A0boss=E6=AD=BB?= =?UTF-8?q?=E4=BA=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/main.go | 2 +- .../fight/effect/effect_10-16_94_99_114.go | 4 +- logic/service/fight/effect/effect_117.go | 2 +- logic/service/fight/effect/effect_62.go | 15 ++-- logic/service/fight/fightc.go | 74 ++----------------- .../fight/input/{node.go => effect.go} | 2 + logic/service/fight/input/fight.go | 11 +++ logic/service/fight/input/input.go | 32 +++++++- .../fight/input/{effecti.go => interface.go} | 0 9 files changed, 61 insertions(+), 81 deletions(-) rename logic/service/fight/input/{node.go => effect.go} (98%) rename logic/service/fight/input/{effecti.go => interface.go} (100%) diff --git a/logic/main.go b/logic/main.go index b7bacf34f..002cba8bb 100644 --- a/logic/main.go +++ b/logic/main.go @@ -33,7 +33,7 @@ func PprofWeb() { } } func signalHandlerForMain(sig os.Signal) { - fight.Fightpool.Free() + fight.Fightpool.ReleaseTimeout(100) player.Mainplayer.Range(func(key uint32, value *player.Player) bool { value.Save() diff --git a/logic/service/fight/effect/effect_10-16_94_99_114.go b/logic/service/fight/effect/effect_10-16_94_99_114.go index 5976a4a4e..7b35c071c 100644 --- a/logic/service/fight/effect/effect_10-16_94_99_114.go +++ b/logic/service/fight/effect/effect_10-16_94_99_114.go @@ -70,8 +70,8 @@ func (e *Effect10) OnSkill(ctx input.Ctx) bool { // 持续回合 if duration == 0 { - duration = int(e.Input.FightC.GetRand().Int31n(2)) // 默认随机 1~3 回合 - duration++ + duration = int(e.Input.FightC.GetRand().Int31n(3)) // 默认随机 1~3 回合 + //duration++ } // 获取状态效果 diff --git a/logic/service/fight/effect/effect_117.go b/logic/service/fight/effect/effect_117.go index ab5ee96fc..103049bc9 100644 --- a/logic/service/fight/effect/effect_117.go +++ b/logic/service/fight/effect/effect_117.go @@ -46,7 +46,7 @@ func (e *Effect117) OnSkill(ctx input.Ctx) bool { if eff == nil { return true } - duration := int(e.Input.FightC.GetRand().Int31n(2)) // 默认随机 1~3 回合 + duration := int(e.Input.FightC.GetRand().Int31n(3)) // 默认随机 1~3 回合 eff.Duration(duration) ctx.AddEffect(eff) diff --git a/logic/service/fight/effect/effect_62.go b/logic/service/fight/effect/effect_62.go index 36e0fee74..e045186af 100644 --- a/logic/service/fight/effect/effect_62.go +++ b/logic/service/fight/effect/effect_62.go @@ -4,6 +4,7 @@ import ( "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" "blazing/logic/service/fight/node" + "sync" "github.com/shopspring/decimal" ) @@ -16,6 +17,7 @@ type Effect62 struct { Hide bool // 是否隐藏 正常是命中就可用,镇魂歌是回合数到才可用 opp *input.Input e *Effect62_sub + l sync.Once } type Effect62_sub struct { node.EffectNode @@ -71,9 +73,10 @@ func (e *Effect62) Turn_Start(ctx input.Ctx) { } func (e *Effect62) OnSkill(ctx input.Ctx) bool { if !e.Hit() { - e.Alive(false) + //e.Alive(false) return true } + e.opp = ctx.Input e.e = &Effect62_sub{ EffectNode: node.EffectNode{}, @@ -81,19 +84,13 @@ func (e *Effect62) OnSkill(ctx input.Ctx) bool { bind: ctx.Input, } e.e.ID(e.ID() + int(input.EffectType.Sub)) //子效果ID + e.e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) //给对方添加我方施加的buff e.e.SetArgs(e.Input, e.SideEffectArgs...) + return true } -// 默认添加回合 -func (e *Effect62) SetArgs(t *input.Input, a ...int) { - - e.EffectNode.SetArgs(t, a...) - - e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0] + 1) -} - // // 因为对方切精灵,这个效果也要无效掉 // func (this *Effect62) OnSwitchIn(input.Ctx) bool { // if this.Hide { //如果还在隐藏,就直接返回 diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 8a7872c89..a5c58ce15 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -547,6 +547,8 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { } + f.First.GenSataus() + f.Second.GenSataus() f.First.Exec(func(t input.Effect) bool { //这个是能否使用技能 //结算状态 t.Turn_End(input.Ctx{ @@ -562,32 +564,16 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { }) return true }) - f.First.RemainHp = int32(f.First.CurrentPet.Info.Hp) - f.First.SkillList = f.First.CurrentPet.Info.SkillList - f.Second.SkillList = f.Second.CurrentPet.Info.SkillList - f.Second.RemainHp = int32(f.Second.CurrentPet.Info.Hp) + f.First.GenInfo() + f.Second.GenInfo() + // ret.FAttack = *f.First.AttackValue + // ret.SAttack = *f.Second.AttackValue ret := info.AttackValueS{ + FAttack: *f.First.AttackValue, SAttack: *f.Second.AttackValue, } - - for i := 0; i < 20; i++ { //堆叠状态剩余回合 - - t := f.First.GetEffect(input.EffectType.Status, i) - - if t != nil { //状态都是叠层类的 - - ret.FAttack.Status[i] = int8(t.Duration()) + 1 - - } - t = f.Second.GetEffect(input.EffectType.Status, i) - if t != nil { - ret.SAttack.Status[i] = int8(t.Duration()) + 1 - } - - } - f.Broadcast(func(ff *input.Input) { for _, v := range f.Switch { @@ -601,49 +587,3 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { }) f.Switch = []*action.ActiveSwitchAction{} } - -// 处理战斗中宠物死亡后的逻辑(同归于尽+胜利判定) -// i=0 表示当前攻击者是先手方,i=1 表示当前攻击者是后手方 -func (f *FightC) handlePetDeath(attacker, defender *input.Input, i int) { - // 辅助函数:根据攻击者顺序获取胜利者ID - getWinnerID := func() uint32 { - if i == 0 { - // 若攻击者是先手方,胜利方为后手方(defender对应的玩家) - return defender.Player.GetInfo().UserID - } - // 若攻击者是后手方,胜利方为先手方(attacker对应的玩家) - return attacker.Player.GetInfo().UserID - } - - // 1. 处理攻击方宠物死亡的情况 - if attacker.CurrentPet.Info.Hp <= 0 { - // 同归于尽:攻击方死亡时,若防守方也死亡,给防守方留1点血 - if defender.CurrentPet.Info.Hp == 0 { - defender.CurrentPet.Info.Hp = 1 - } - - // 检查是否战斗结束(攻击方死亡后,判定防守方胜利) - if f.IsWin(defender, attacker.CurrentPet.Info.CatchTime) { - f.FightOverInfo.WinnerId = getWinnerID() - f.closefight = true - return // 战斗结束,提前返回 - } - } - - // 2. 处理防守方宠物死亡的情况(若战斗未结束) - if !f.closefight && defender.CurrentPet.Info.Hp == 0 { - // 同归于尽:防守方死亡时,若攻击方也死亡,给攻击方留1点血 - if attacker.CurrentPet.Info.Hp == 0 { - attacker.CurrentPet.Info.Hp = 1 - } - - // 防守方被击败,允许切换精灵 - defender.CanChange = true - - // 检查是否战斗结束(防守方死亡后,判定攻击方胜利) - if f.IsWin(attacker, defender.CurrentPet.Info.CatchTime) { - f.FightOverInfo.WinnerId = getWinnerID() - f.closefight = true - } - } -} diff --git a/logic/service/fight/input/node.go b/logic/service/fight/input/effect.go similarity index 98% rename from logic/service/fight/input/node.go rename to logic/service/fight/input/effect.go index 75785db92..1dfc3e4b1 100644 --- a/logic/service/fight/input/node.go +++ b/logic/service/fight/input/effect.go @@ -1,6 +1,7 @@ package input import ( + "blazing/common/utils" "blazing/logic/service/fight/info" "fmt" @@ -139,6 +140,7 @@ func (c *Input) AddEffect(e Effect) { equalInts(v.GetArgs(), e.GetArgs()) { //如果层数可以叠加或者是无限层数 if v.MaxStack() == 0 { v.Alive(false) //不允许叠层,取消效果 + e.Duration(utils.Max(e.Duration(), v.Duration())) } else { ///e.Alive(false) //取消之前效果 diff --git a/logic/service/fight/input/fight.go b/logic/service/fight/input/fight.go index f1f301e8f..91dd96b28 100644 --- a/logic/service/fight/input/fight.go +++ b/logic/service/fight/input/fight.go @@ -317,6 +317,17 @@ func (u *Input) SetProp(in *Input, prop, level int8, ptype info.EnumAbilityOpTyp func (i *Input) GetAction(opp *Input) { // 获取己方当前宠物和对方当前宠物 selfPet := i.FightC.GetCurrPET(i.Player) + //没血就切换精灵 + if selfPet.Info.Hp <= 0 { + for _, v := range i.AllPet { + if v.Info.Hp>0 { + i.FightC.ChangePet(i.Player,v.Info.CatchTime) + return + } + + } + + } //oppPet := opp.FightC.GetCurrPET(opp.Player) skills := selfPet.Skills diff --git a/logic/service/fight/input/input.go b/logic/service/fight/input/input.go index eb99b1285..b90690841 100644 --- a/logic/service/fight/input/input.go +++ b/logic/service/fight/input/input.go @@ -20,7 +20,7 @@ type Input struct { *info.AttackValue FightC common.FightI // info.BattleActionI - Effects []Effect //effects 实际上全局就是effect无限回合 //effects容器 技能的 + Effects []Effect //effects 实际上全局就是effect无限回合 //effects容器 技能的 DamageZone struct { Damage decimal.Decimal //伤害 BeforeADD decimal.Decimal //攻击伤害 @@ -53,6 +53,36 @@ func (i *Input) GetPetInfo() *info.BattlePetEntity { return i.CurrentPet +} +func (input *Input) GenSataus() { + + for i := 0; i < 20; i++ { //堆叠状态剩余回合 + + t := input.GetEffect(EffectType.Status, i) + + if t != nil { //状态都是叠层类的 + + input.AttackValue.Status[i] = int8(t.Duration()) + + } + // t = f.Second.GetEffect(input.EffectType.Status, i) + // if t != nil { + // ret.SAttack.Status[i] = int8(t.Duration()) + 1 + // } + + } + +} +func (input *Input) GenInfo() { + + input.RemainHp = int32(input.CurrentPet.Info.Hp) + input.SkillList = input.CurrentPet.Info.SkillList + + // f.Second.SkillList = f.Second.CurrentPet.Info.SkillList + // f.Second.RemainHp = int32(f.Second.CurrentPet.Info.Hp) + // ret.FAttack = *f.First.AttackValue + // ret.SAttack = *f.Second.AttackValue + } func (i *Input) ResetAttackValue() { i.AttackValue.SkillID = 0 diff --git a/logic/service/fight/input/effecti.go b/logic/service/fight/input/interface.go similarity index 100% rename from logic/service/fight/input/effecti.go rename to logic/service/fight/input/interface.go