198 lines
4.8 KiB
Go
198 lines
4.8 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"
|
||
"github.com/gogf/gf/v2/util/grand"
|
||
)
|
||
|
||
var effect1345ControlStatuses = []int{
|
||
int(info.PetStatus.Paralysis),
|
||
int(info.PetStatus.Tired),
|
||
int(info.PetStatus.Fear),
|
||
int(info.PetStatus.Petrified),
|
||
int(info.PetStatus.Sleep),
|
||
}
|
||
|
||
func addRandomControlStatuses1345(owner, target *input.Input, count int) bool {
|
||
if owner == nil || target == nil || count <= 0 {
|
||
return false
|
||
}
|
||
if count > len(effect1345ControlStatuses) {
|
||
count = len(effect1345ControlStatuses)
|
||
}
|
||
|
||
applied := false
|
||
for _, idx := range grand.Perm(len(effect1345ControlStatuses))[:count] {
|
||
if addStatusByID(owner, target, effect1345ControlStatuses[idx]) {
|
||
applied = true
|
||
}
|
||
}
|
||
return applied
|
||
}
|
||
|
||
// Effect 1343: 消除对手回合类效果,消除成功则下{0}次受到的伤害转化为自身体力
|
||
type Effect1343 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1343) Skill_Use() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
|
||
before := activeTurnEffectCount(e.Ctx().Opp)
|
||
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
|
||
if before <= 0 {
|
||
return true
|
||
}
|
||
|
||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1343, int(e.Args()[0].IntPart()))
|
||
if sub != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1343Sub struct {
|
||
node.EffectNode
|
||
remaining int
|
||
}
|
||
|
||
func (e *Effect1343Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
if len(a) > 0 {
|
||
e.remaining = a[0]
|
||
}
|
||
}
|
||
|
||
func (e *Effect1343Sub) DamageLockEx(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || e.remaining <= 0 {
|
||
return true
|
||
}
|
||
if zone.Damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
heal := zone.Damage
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, heal)
|
||
zone.Damage = alpacadecimal.Zero
|
||
e.remaining--
|
||
if e.remaining <= 0 {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1344: 全属性+{0},后出手时自身强化效果翻倍
|
||
type Effect1344 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1344) OnSkill() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
|
||
boost := int8(e.Args()[0].IntPart())
|
||
if !e.IsFirst() {
|
||
boost *= 2
|
||
}
|
||
for i := range e.Ctx().Our.Prop[:] {
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), boost)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1345: 消耗自身全部体力,{0}%令对手进入{1}种控制类异常状态,未触发异常状态则附加对手最大体力1/{2}的百分比伤害
|
||
type Effect1345 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1345) Skill_Use() bool {
|
||
if len(e.Args()) < 3 {
|
||
return true
|
||
}
|
||
|
||
if e.Ctx().Our.CurPet[0] != nil {
|
||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: e.Ctx().Our.CurPet[0].GetHP(),
|
||
})
|
||
}
|
||
|
||
triggered := false
|
||
ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
|
||
if ok {
|
||
triggered = addRandomControlStatuses1345(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart()))
|
||
}
|
||
if triggered || e.Args()[2].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
damage := e.Ctx().Opp.CurPet[0].GetMaxHP().Div(e.Args()[2])
|
||
if damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: damage,
|
||
})
|
||
return true
|
||
}
|
||
|
||
// Effect 1346: {0}回合内每回合{1}%令自身全属性+{2},未触发则令对手全属性-{3}
|
||
type Effect1346 struct{ RoundEffectArg0Base }
|
||
|
||
func (e *Effect1346) OnSkill() bool {
|
||
if len(e.Args()) < 4 {
|
||
return true
|
||
}
|
||
|
||
ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
|
||
if ok {
|
||
boost := int8(e.Args()[2].IntPart())
|
||
for i := range e.Ctx().Our.Prop[:] {
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), boost)
|
||
}
|
||
return true
|
||
}
|
||
|
||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[3].IntPart()))
|
||
return true
|
||
}
|
||
|
||
// Effect 1347: 反转对手能力提升状态,反转成功则令对手{0},反转失败则消除对手能力提升状态
|
||
type Effect1347 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1347) Skill_Use() bool {
|
||
if len(e.Args()) == 0 {
|
||
return true
|
||
}
|
||
|
||
reversed := false
|
||
for i, v := range e.Ctx().Opp.Prop[:] {
|
||
if v <= 0 {
|
||
continue
|
||
}
|
||
if e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), -2*v) {
|
||
reversed = true
|
||
}
|
||
}
|
||
if reversed {
|
||
addStatusByID(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[0].IntPart()))
|
||
return true
|
||
}
|
||
|
||
clearPositiveProps(e.Ctx().Opp, e.Ctx().Our)
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 1343, &Effect1343{})
|
||
input.InitEffect(input.EffectType.Sub, 1343, &Effect1343Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1344, &Effect1344{})
|
||
input.InitEffect(input.EffectType.Skill, 1345, &Effect1345{})
|
||
input.InitEffect(input.EffectType.Skill, 1346, &Effect1346{})
|
||
input.InitEffect(input.EffectType.Skill, 1347, &Effect1347{})
|
||
}
|