239 lines
6.5 KiB
Go
239 lines
6.5 KiB
Go
package effect
|
||
|
||
import (
|
||
"strings"
|
||
|
||
"blazing/common/data/share"
|
||
"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"
|
||
)
|
||
|
||
const titanSpiritItemID = 1400352
|
||
|
||
// Effect 1609: 召唤自己的伙伴进行5-10次攻击,布布犬发起时可额外令自身下回合攻击造成的伤害翻倍
|
||
type Effect1609 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1609) SkillHit() bool {
|
||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
|
||
return true
|
||
}
|
||
hits := 5 + grand.Intn(6)
|
||
if hits > 1 {
|
||
e.Ctx().SkillEntity.AttackTime += uint32(hits - 1)
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1609) Skill_Use() bool {
|
||
if e.Ctx().Our == nil || e.Ctx().Our.CurPet[0] == nil {
|
||
return true
|
||
}
|
||
if strings.TrimSpace(e.Ctx().Our.CurPet[0].PetInfo.DefName) != "布布犬" {
|
||
return true
|
||
}
|
||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1609)
|
||
if sub != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1609Sub struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1609Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(1)
|
||
e.CanStack(false)
|
||
}
|
||
|
||
func (e *Effect1609Sub) Damage_Mul(zone *info.DamageZone) bool {
|
||
if 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(2))
|
||
return true
|
||
}
|
||
|
||
// Effect 1610: 召唤自己的伙伴进行5-10次攻击,布布熊发起时可额外令对手下回合属性技能失效
|
||
type Effect1610 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1610) SkillHit() bool {
|
||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS || e.Ctx().SkillEntity.AttackTime == 0 {
|
||
return true
|
||
}
|
||
hits := 5 + grand.Intn(6)
|
||
if hits > 1 {
|
||
e.Ctx().SkillEntity.AttackTime += uint32(hits - 1)
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1610) Skill_Use() bool {
|
||
if e.Ctx().Opp == nil || e.Ctx().Our == nil || e.Ctx().Our.CurPet[0] == nil {
|
||
return true
|
||
}
|
||
if strings.TrimSpace(e.Ctx().Our.CurPet[0].PetInfo.DefName) != "布布熊" {
|
||
return true
|
||
}
|
||
sub := e.Ctx().Opp.InitEffect(input.EffectType.Sub, 1610)
|
||
if sub != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1610Sub struct {
|
||
FixedDuration1Base
|
||
}
|
||
|
||
func (e *Effect1610Sub) SkillHit_ex() bool {
|
||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() != info.Category.STATUS {
|
||
return true
|
||
}
|
||
e.Ctx().SkillEntity.SetNoSide()
|
||
e.Ctx().SkillEntity.AttackTime = 0
|
||
return true
|
||
}
|
||
|
||
// Effect 1611: 攻击命中后5%的概率汲取泰坦源脉的力量,本次攻击造成5倍伤害且战斗结束后获得5000泰坦之灵(每日上限50000)
|
||
type Effect1611 struct {
|
||
node.EffectNode
|
||
rolled bool
|
||
triggered bool
|
||
rewarded bool
|
||
}
|
||
|
||
func (e *Effect1611) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
}
|
||
|
||
func (e *Effect1611) SkillHit() bool {
|
||
e.rolled = false
|
||
e.triggered = false
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1611) Damage_Mul(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
if !e.rolled {
|
||
e.rolled = true
|
||
if ok, _, _ := e.Input.Player.Roll(5, 100); ok {
|
||
e.triggered = true
|
||
e.rewarded = true
|
||
}
|
||
}
|
||
if !e.triggered {
|
||
return true
|
||
}
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(5))
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1611) OnBattleEnd() bool {
|
||
if !e.rewarded {
|
||
return true
|
||
}
|
||
player := e.Ctx().Our.Player
|
||
if player == nil || player.GetInfo().UserID == 0 {
|
||
return true
|
||
}
|
||
count, err := share.GlobalCounterManager.GetCount(&share.DailyPeriod, player.GetInfo().UserID, 1611)
|
||
if err != nil && err != share.ErrCacheMiss {
|
||
return true
|
||
}
|
||
if err == share.ErrCacheMiss {
|
||
count = 0
|
||
}
|
||
if count >= 10 {
|
||
return true
|
||
}
|
||
if !player.ItemAdd(titanSpiritItemID, 5000) {
|
||
return true
|
||
}
|
||
_, _ = share.GlobalCounterManager.IncrCount(&share.DailyPeriod, player.GetInfo().UserID, 1611)
|
||
return true
|
||
}
|
||
|
||
// Effect 1612: {0}回合内受到的伤害低于{1}时{2}%令对手{3},未触发则附加{4}点固定伤害
|
||
type Effect1612 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1612) Skill_Use() bool {
|
||
sub := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1612, e.SideEffectArgs...)
|
||
if sub != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, sub)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1612Sub struct{ RoundEffectArg0Base }
|
||
|
||
func (e *Effect1612Sub) DamageSubEx(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 5 {
|
||
return true
|
||
}
|
||
if zone.Damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
threshold := e.Args()[1]
|
||
chance := int(e.Args()[2].IntPart())
|
||
statusID := int(e.Args()[3].IntPart())
|
||
fallback := e.Args()[4]
|
||
triggered := false
|
||
if zone.Damage.Cmp(threshold) < 0 && chance > 0 && statusID > 0 {
|
||
if ok, _, _ := e.Input.Player.Roll(chance, 100); ok {
|
||
addStatusByID(e.Ctx().Our, e.Ctx().Opp, statusID)
|
||
triggered = true
|
||
}
|
||
}
|
||
if !triggered && fallback.Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: fallback})
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1613: 自身不处于能力提升状态则吸取对手{0}点体力,若先出手则额外吸取{1}点体力
|
||
type Effect1613 struct{ node.EffectNode }
|
||
|
||
func (e *Effect1613) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || e.Ctx().Opp == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().Our == nil || e.Ctx().Our.CurPet[0] == nil {
|
||
return true
|
||
}
|
||
drain := alpacadecimal.Zero
|
||
if !e.Ctx().Our.HasPropADD() {
|
||
drain = drain.Add(e.Args()[0])
|
||
}
|
||
if e.IsFirst() {
|
||
drain = drain.Add(e.Args()[1])
|
||
}
|
||
if drain.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
damageByFixed(e.Ctx().Our, e.Ctx().Opp, drain.IntPart())
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, drain)
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 1609, &Effect1609{})
|
||
input.InitEffect(input.EffectType.Sub, 1609, &Effect1609Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1610, &Effect1610{})
|
||
input.InitEffect(input.EffectType.Sub, 1610, &Effect1610Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1611, &Effect1611{})
|
||
input.InitEffect(input.EffectType.Skill, 1612, &Effect1612{})
|
||
input.InitEffect(input.EffectType.Sub, 1612, &Effect1612Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1613, &Effect1613{})
|
||
}
|