refactor(fight): 重构技能效果属主逻辑
- 修改 EffectNode 中的 Target 方法,重命名为 GetOwner,用于获取技能属主 - 更新 SetTarget 方法,重命名为 SetOwner,用于设置技能属主 - 在 NodeManager 中使用新的 GetOwner 方法来判断技能属主 - 在 FightC 中使用新的 SetOwner 方法来设置技能属主 - 新增判断玩家是否放弃战斗的逻辑
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user