332 lines
9.1 KiB
Go
332 lines
9.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"
|
||
)
|
||
|
||
const effect1514SpecialPetName = "混元天尊"
|
||
|
||
var effect151xBahuangMaxHPLoss = alpacadecimal.NewFromInt(20)
|
||
|
||
func reduceCurrentPetMaxHPFlat(target *input.Input, loss alpacadecimal.Decimal) bool {
|
||
if target == nil || target.CurrentPet == nil || loss.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return false
|
||
}
|
||
|
||
currentMax := target.CurrentPet.GetMaxHP()
|
||
if currentMax.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return false
|
||
}
|
||
|
||
newMax := currentMax.Sub(loss)
|
||
if newMax.Cmp(alpacadecimal.NewFromInt(1)) < 0 {
|
||
newMax = alpacadecimal.NewFromInt(1)
|
||
}
|
||
if newMax.Cmp(currentMax) >= 0 {
|
||
return false
|
||
}
|
||
|
||
target.CurrentPet.Info.MaxHp = uint32(newMax.IntPart())
|
||
if target.CurrentPet.Info.Hp > target.CurrentPet.Info.MaxHp {
|
||
target.CurrentPet.Info.Hp = target.CurrentPet.Info.MaxHp
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1513: {0}回合内{1}%令对手{2},未触发则削减对手{3}点体力上限
|
||
type Effect1513 struct{ RoundEffectArg0Base }
|
||
|
||
func (e *Effect1513) OnSkill() bool {
|
||
if len(e.Args()) < 4 {
|
||
return true
|
||
}
|
||
|
||
statusID := int(e.Args()[2].IntPart())
|
||
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
|
||
if statusID > 0 {
|
||
addStatusByID(e.Ctx().Our, e.Ctx().Opp, statusID)
|
||
}
|
||
return true
|
||
}
|
||
|
||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, e.Args()[3])
|
||
return true
|
||
}
|
||
|
||
// Effect 1514: 消耗自身所有体力,令自身下只登场精灵获得2次八荒之力效果,若自身下只登场精灵为混元天尊则转变为3次
|
||
type Effect1514 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1514) Skill_Use() bool {
|
||
if e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: e.Ctx().Our.CurrentPet.GetHP()})
|
||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1514)
|
||
if sub != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1514PendingSub struct{ node.EffectNode }
|
||
|
||
func (e *Effect1514PendingSub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
e.CanStack(false)
|
||
}
|
||
|
||
func (e *Effect1514PendingSub) SwitchIn(in *input.Input) bool {
|
||
if in != e.Ctx().Our || e.Ctx().Our == nil || e.Ctx().Our.CurrentPet == nil {
|
||
return true
|
||
}
|
||
|
||
remaining := 2
|
||
if e.Ctx().Our.CurrentPet.Info.Name == effect1514SpecialPetName {
|
||
remaining = 3
|
||
}
|
||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 15141, remaining)
|
||
if sub != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
|
||
type Effect1514BahuangSub struct {
|
||
node.EffectNode
|
||
trackedPet *info.BattlePetEntity
|
||
remaining int
|
||
active bool
|
||
}
|
||
|
||
func (e *Effect1514BahuangSub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
e.CanStack(false)
|
||
e.trackedPet = t.CurrentPet
|
||
if len(a) > 0 {
|
||
e.remaining = a[0]
|
||
}
|
||
}
|
||
|
||
func (e *Effect1514BahuangSub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if e.trackedPet == nil || e.Ctx().Our.CurrentPet != e.trackedPet || 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 += 1
|
||
e.active = true
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1514BahuangSub) Damage_Mul(zone *info.DamageZone) bool {
|
||
if !e.active || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(150)).Div(hundred)
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1514BahuangSub) OnSkill() bool {
|
||
if !e.active || e.remaining <= 0 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
|
||
return true
|
||
}
|
||
|
||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, effect151xBahuangMaxHPLoss)
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1514BahuangSub) finish() bool {
|
||
if !e.active {
|
||
return true
|
||
}
|
||
|
||
e.remaining--
|
||
e.active = false
|
||
if e.remaining <= 0 {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1514BahuangSub) Action_end() bool { return e.finish() }
|
||
func (e *Effect1514BahuangSub) Action_end_ex() bool { return e.finish() }
|
||
|
||
func (e *Effect1514BahuangSub) SwitchOut(in *input.Input) bool {
|
||
if in == e.Ctx().Our {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1515: 对手体力上限高于{0}则造成的攻击伤害提升{1}%,对手体力上限低于{2}则附加自身{3}值{4}%的百分比伤害
|
||
type Effect1515 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1515) Damage_Mul(zone *info.DamageZone) bool {
|
||
if len(e.Args()) < 5 || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().Opp.CurrentPet.GetMaxHP().Cmp(e.Args()[0]) <= 0 {
|
||
return true
|
||
}
|
||
|
||
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[1])).Div(hundred)
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1515) OnSkill() bool {
|
||
if len(e.Args()) < 5 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().Opp.CurrentPet.GetMaxHP().Cmp(e.Args()[2]) >= 0 {
|
||
return true
|
||
}
|
||
|
||
propID := int(e.Args()[3].IntPart())
|
||
if propID < 0 || propID >= 6 {
|
||
return true
|
||
}
|
||
|
||
damage := e.Ctx().Our.GetProp(propID).Mul(e.Args()[4]).Div(hundred)
|
||
if damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: damage})
|
||
return true
|
||
}
|
||
|
||
// Effect 1516: 汇聚无尽的怨气,使用后下3回合自身获得八荒之力效果
|
||
type Effect1516 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1516) Skill_Use() bool {
|
||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1516)
|
||
if sub != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1516Sub struct {
|
||
node.EffectNode
|
||
trackedPet *info.BattlePetEntity
|
||
active bool
|
||
}
|
||
|
||
func (e *Effect1516Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(3)
|
||
e.CanStack(false)
|
||
e.trackedPet = t.CurrentPet
|
||
}
|
||
|
||
func (e *Effect1516Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if e.trackedPet == nil || e.Ctx().Our.CurrentPet != e.trackedPet {
|
||
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 += 1
|
||
e.active = true
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1516Sub) Damage_Mul(zone *info.DamageZone) bool {
|
||
if !e.active || zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(150)).Div(hundred)
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1516Sub) OnSkill() bool {
|
||
if !e.active || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
|
||
return true
|
||
}
|
||
|
||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, effect151xBahuangMaxHPLoss)
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1516Sub) Action_end() bool {
|
||
e.active = false
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1516Sub) Action_end_ex() bool {
|
||
e.active = false
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1516Sub) SwitchOut(in *input.Input) bool {
|
||
if in == e.Ctx().Our {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1517: 当回合击败对手则削减对手下只登场精灵{0}点体力上限
|
||
type Effect1517 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1517) Skill_Use() bool {
|
||
if len(e.Args()) == 0 || e.Ctx().Opp == nil || e.Ctx().Opp.CurrentPet == nil || e.Ctx().Opp.CurrentPet.Info.Hp > 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
sub := e.Ctx().Opp.InitEffect(input.EffectType.Sub, 1517, int(e.Args()[0].IntPart()))
|
||
if sub != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1517Sub struct{ node.EffectNode }
|
||
|
||
func (e *Effect1517Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(1)
|
||
e.CanStack(false)
|
||
}
|
||
|
||
func (e *Effect1517Sub) SwitchIn(in *input.Input) bool {
|
||
if in != e.Ctx().Opp || len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
|
||
reduceCurrentPetMaxHPFlat(e.Ctx().Opp, e.Args()[0])
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 1513, &Effect1513{})
|
||
input.InitEffect(input.EffectType.Skill, 1514, &Effect1514{})
|
||
input.InitEffect(input.EffectType.Sub, 1514, &Effect1514PendingSub{})
|
||
input.InitEffect(input.EffectType.Sub, 15141, &Effect1514BahuangSub{})
|
||
input.InitEffect(input.EffectType.Skill, 1515, &Effect1515{})
|
||
input.InitEffect(input.EffectType.Skill, 1516, &Effect1516{})
|
||
input.InitEffect(input.EffectType.Sub, 1516, &Effect1516Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1517, &Effect1517{})
|
||
input.InitEffect(input.EffectType.Sub, 1517, &Effect1517Sub{})
|
||
}
|