From 41b150e614739cfea57bafa90f8e4d22c37f7f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Mon, 8 Sep 2025 23:17:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor(fight):=20=E9=87=8D=E6=9E=84=E6=8A=80?= =?UTF-8?q?=E8=83=BD=E6=95=88=E6=9E=9C=E5=B1=9E=E4=B8=BB=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 EffectNode 中的 Target 方法,重命名为 GetOwner,用于获取技能属主 - 更新 SetTarget 方法,重命名为 SetOwner,用于设置技能属主 - 在 NodeManager 中使用新的 GetOwner 方法来判断技能属主 - 在 FightC 中使用新的 SetOwner 方法来设置技能属主 - 新增判断玩家是否放弃战斗的逻辑 --- logic/service/fight/battle/node/node.go | 10 ++++------ logic/service/fight/info/nodemanger.go | 8 ++++---- logic/service/fightc.go | 8 +++++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/logic/service/fight/battle/node/node.go b/logic/service/fight/battle/node/node.go index b38eccda..18d31b19 100644 --- a/logic/service/fight/battle/node/node.go +++ b/logic/service/fight/battle/node/node.go @@ -28,16 +28,14 @@ func (this *EffectNode) ID() int { return 0 } +func (this *EffectNode) GetOwner() bool { -// 传出作用对象,默认0是自身,1是作用于对面 -func (this *EffectNode) Target() bool { - - return this.target + return this.Owner } -func (this *EffectNode) SetTarget(t bool) { +func (this *EffectNode) SetOwner(b bool) { - this.target = t + this.Owner = b } func (this *EffectNode) Stack(t int) int { diff --git a/logic/service/fight/info/nodemanger.go b/logic/service/fight/info/nodemanger.go index 9c62db61..5d90005e 100644 --- a/logic/service/fight/info/nodemanger.go +++ b/logic/service/fight/info/nodemanger.go @@ -27,9 +27,9 @@ type Effect interface { OnHit() bool // 技能命中时触发 OnMiss() bool // 技能未命中时触发 AfterAttacked() bool // 被攻击后触发(受击判定) - Target() bool // 技能效果类型 - SetTarget(bool) // 技能效果类型 - OnDefeat() bool // 精灵被击败时触发 + GetOwner() bool // 技能属主,比如寄生和镇魂歌,属主是对方) + SetOwner(bool) + OnDefeat() bool // 精灵被击败时触发 TurnEnd() bool // 回合结束 @@ -149,7 +149,7 @@ func (c *NodeManager) CancelTurn(efftype bool) { var remain []Effect for _, eff := range c.Effects { - if eff.Duration(0) <= 0 && eff.Target() == efftype { //false是自身,true是对方,反转后为真就是自己的 + if eff.Duration(0) <= 0 && eff.GetOwner() == efftype { //false是自身,true是对方,反转后为真就是自己的 remain = append(remain, eff) } } diff --git a/logic/service/fightc.go b/logic/service/fightc.go index b9bcc8ec..382d1081 100644 --- a/logic/service/fightc.go +++ b/logic/service/fightc.go @@ -117,6 +117,11 @@ func (f *FightC) ChangePet(c PlayerI, id int32) { // 玩家使用技能 func (f *FightC) UseSkill(c PlayerI, id int32) { + + if id == 0 { + f.actionChan <- &info.SystemGiveUpAction{PlayerID: c.ID()} + return + } ret := &info.SelectSkillAction{ PlayerID: c.ID(), } @@ -300,6 +305,7 @@ func (f *FightC) battleLoop() { } // 双方动作齐了,取出来结算 + //todo 如果一方没有选择,实际上就是后端判断PP是否还有,前端是直接发的 p1Action := actions[f.Our.Player.ID()] p2Action := actions[f.Opp.Player.ID()] fmt.Println("开始结算回合") @@ -389,7 +395,7 @@ func (f *FightC) parseskill(id *info.SelectSkillAction) { //如果不是是房主方,说明施加的对象是反的,比如本来是false,实际上是给邀请方施加的 //所以这里要对target取反 if id.GetPlayerID() != f.OwnerID { - t.SetTarget(!t.Target()) + t.SetOwner(!t.GetOwner()) } temparg = temparg[args:] f.EffectS.AddEffect(deepcopy.Copy(t).(info.Effect))