143 lines
3.1 KiB
Go
143 lines
3.1 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/action"
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
"blazing/logic/service/fight/node"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// Effect 17: 1回合等待,次回合攻击
|
||
type Effect17 struct {
|
||
node.EffectNode
|
||
releaseSkill *info.SkillEntity
|
||
releasing bool
|
||
}
|
||
|
||
func (e *Effect17) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(1)
|
||
}
|
||
|
||
func (e *Effect17) TurnStart(fattack, sattack *action.SelectSkillAction) {
|
||
if e.Duration() != 0 || e.releaseSkill == nil {
|
||
return
|
||
}
|
||
|
||
nextAction := e.findActionByPlayer(fattack, sattack)
|
||
if nextAction == nil {
|
||
return
|
||
}
|
||
|
||
releaseSkill := cloneSkillEntity(e.releaseSkill)
|
||
if releaseSkill == nil {
|
||
return
|
||
}
|
||
if releaseSkill.Info != nil && releaseSkill.Info.PP == 0 {
|
||
releaseSkill.Info.PP = 1
|
||
}
|
||
|
||
nextAction.SkillEntity = releaseSkill
|
||
e.releasing = true
|
||
}
|
||
|
||
func (e *Effect17) ActionStart(fattack, sattack *action.SelectSkillAction) bool {
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
|
||
if e.Duration() == 0 && e.releasing {
|
||
return true
|
||
}
|
||
|
||
if e.releaseSkill == nil {
|
||
e.releaseSkill = e.buildReleaseSkill(e.Ctx().SkillEntity)
|
||
}
|
||
|
||
// 蓄力回合仅保留 Effect17 自身,避免同技能其他副作用提前触发。
|
||
for _, effect := range e.Ctx().Our.EffectCache {
|
||
if effect == e {
|
||
continue
|
||
}
|
||
effect.Alive(false)
|
||
}
|
||
|
||
e.Ctx().SkillEntity.XML.Power = 0
|
||
return true
|
||
}
|
||
|
||
func (e *Effect17) DamageLock(zone *info.DamageZone) bool {
|
||
if e.Duration() > 0 && zone.Type == info.DamageType.Red {
|
||
zone.Damage = alpacadecimal.Zero
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect17) HookPP(count *int) bool {
|
||
if e.Duration() == 0 && e.releasing {
|
||
*count = 0
|
||
e.releasing = false
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect17) SwitchOut(in *input.Input) bool {
|
||
if in == e.Ctx().Our {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect17) findActionByPlayer(fattack, sattack *action.SelectSkillAction) *action.SelectSkillAction {
|
||
playerID := e.Input.Player.GetInfo().UserID
|
||
if fattack != nil && fattack.GetPlayerID() == playerID {
|
||
return fattack
|
||
}
|
||
if sattack != nil && sattack.GetPlayerID() == playerID {
|
||
return sattack
|
||
}
|
||
return nil
|
||
}
|
||
|
||
func (e *Effect17) buildReleaseSkill(skill *info.SkillEntity) *info.SkillEntity {
|
||
releaseSkill := cloneSkillEntity(skill)
|
||
if releaseSkill == nil {
|
||
return nil
|
||
}
|
||
|
||
filteredEffects := make([]int, 0, len(releaseSkill.XML.SideEffectS))
|
||
for _, effectID := range releaseSkill.XML.SideEffectS {
|
||
if effectID == 17 {
|
||
continue
|
||
}
|
||
filteredEffects = append(filteredEffects, effectID)
|
||
}
|
||
releaseSkill.XML.SideEffectS = filteredEffects
|
||
return releaseSkill
|
||
}
|
||
|
||
func cloneSkillEntity(skill *info.SkillEntity) *info.SkillEntity {
|
||
if skill == nil {
|
||
return nil
|
||
}
|
||
|
||
cloned := *skill
|
||
if skill.Info != nil {
|
||
infoCopy := *skill.Info
|
||
cloned.Info = &infoCopy
|
||
}
|
||
|
||
xmlCopy := skill.XML
|
||
xmlCopy.SideEffectS = append([]int(nil), skill.XML.SideEffectS...)
|
||
xmlCopy.SideEffectArgS = append([]int(nil), skill.XML.SideEffectArgS...)
|
||
cloned.XML = xmlCopy
|
||
|
||
return &cloned
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 17, &Effect17{})
|
||
}
|