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" ) var hundred = alpacadecimal.NewFromInt(100) func applyStatusByID(owner, target *input.Input, statusID int) bool { if owner == nil || target == nil || statusID <= 0 { return false } eff := owner.InitEffect(input.EffectType.Status, statusID) if eff == nil { return false } target.AddEffect(owner, eff) return true } // Effect 1578: 出手时自身护盾值高于{0}则自身下回合攻击技能先制+{1} type Effect1578 struct{ node.EffectNode } func (e *Effect1578) Skill_Use() bool { if len(e.Args()) < 2 || e.Ctx().Our == nil { return true } shield := e.Ctx().Our.CurrentShield() if shield.Cmp(e.Args()[0]) <= 0 { return true } sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1578, int(e.Args()[1].IntPart())) if sub != nil { e.Ctx().Our.AddEffect(e.Ctx().Our, sub) } return true } type Effect1578Sub struct { RoundEffectArg0Base remaining int priority int } func (e *Effect1578Sub) SetArgs(t *input.Input, a ...int) { e.EffectNode.SetArgs(t, a...) if len(a) > 0 { e.remaining = 1 } if len(a) > 1 { e.priority = a[0] } } func (e *Effect1578Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool { if e.remaining <= 0 { e.Alive(false) return true } current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID) if current == nil || current.SkillEntity == nil || current.SkillEntity.Category() == info.Category.STATUS { return true } current.SkillEntity.XML.Priority += e.priority e.remaining-- if e.remaining <= 0 { e.Alive(false) } return true } // Effect 1579: 出手时自身护盾值低于{0}则下回合属性技能先制+{1} type Effect1579 struct{ node.EffectNode } func (e *Effect1579) Skill_Use() bool { if len(e.Args()) < 2 || e.Ctx().Our == nil { return true } if e.Ctx().Our.CurrentShield().Cmp(e.Args()[0]) >= 0 { return true } sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1579, int(e.Args()[1].IntPart())) if sub != nil { e.Ctx().Our.AddEffect(e.Ctx().Our, sub) } return true } type Effect1579Sub struct { RoundEffectArg0Base remaining int priority int } func (e *Effect1579Sub) SetArgs(t *input.Input, a ...int) { e.EffectNode.SetArgs(t, a...) if len(a) > 0 { e.remaining = 1 } if len(a) > 1 { e.priority = a[0] } } func (e *Effect1579Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool { if e.remaining <= 0 { e.Alive(false) return true } current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID) if current == nil || current.SkillEntity == nil || current.SkillEntity.Category() != info.Category.STATUS { return true } current.SkillEntity.XML.Priority += e.priority e.remaining-- if e.remaining <= 0 { e.Alive(false) } return true } // Effect 1580: 出手时对手体力高于最大体力的1/{0}则造成伤害的{1}%恢复自身体力 type Effect1580 struct { node.EffectNode shouldHeal bool } func (e *Effect1580) Skill_Use() bool { if len(e.Args()) < 2 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil { return true } maxThreshold := e.Ctx().Opp.CurrentPet.GetMaxHP().Div(e.Args()[0]) if e.Ctx().Opp.CurrentPet.GetHP().Cmp(maxThreshold) <= 0 { return true } e.shouldHeal = true return true } func (e *Effect1580) DamageAdd(zone *info.DamageZone) bool { if !e.shouldHeal || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().Our == nil { return true } if len(e.Args()) < 2 { return true } heal := zone.Damage.Mul(e.Args()[1]).Div(hundred) if heal.Cmp(alpacadecimal.Zero) > 0 { e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal) } e.shouldHeal = false return true } // Effect 1581: 出手时对手体力低于最大体力的1/{0}则造成的伤害提升{1}% type Effect1581 struct{ node.EffectNode } func (e *Effect1581) Damage_Mul(zone *info.DamageZone) bool { if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 { return true } threshold := e.Ctx().Opp.CurrentPet.GetMaxHP().Div(e.Args()[0]) if e.Ctx().Opp.CurrentPet.GetHP().Cmp(threshold) >= 0 { return true } zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[1])).Div(hundred) return true } // Effect 1582: {0}%令对手{1},{2}%令自身{3},均未触发则为自身附加{4}点护盾 type Effect1582 struct{ node.EffectNode } func (e *Effect1582) Skill_Use() bool { if len(e.Args()) < 5 || e.Ctx().Our == nil { return true } opponentTriggered := false if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok { opponentTriggered = applyStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart())) } selfTriggered := false if ok, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100); ok { selfTriggered = applyStatusByID(e.Ctx().Our, e.Ctx().Our, int(e.Args()[3].IntPart())) } if opponentTriggered || selfTriggered { return true } e.Ctx().Our.AddShield(e.Args()[4]) return true } func init() { input.InitEffect(input.EffectType.Skill, 1578, &Effect1578{}) input.InitEffect(input.EffectType.Sub, 1578, &Effect1578Sub{}) input.InitEffect(input.EffectType.Skill, 1579, &Effect1579{}) input.InitEffect(input.EffectType.Sub, 1579, &Effect1579Sub{}) input.InitEffect(input.EffectType.Skill, 1580, &Effect1580{}) input.InitEffect(input.EffectType.Skill, 1581, &Effect1581{}) input.InitEffect(input.EffectType.Skill, 1582, &Effect1582{}) }