217 lines
4.9 KiB
Go
217 lines
4.9 KiB
Go
package effect
|
||
|
||
import (
|
||
element "blazing/common/data/Element"
|
||
"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 petStatusCurse info.EnumPetStatus = 23
|
||
|
||
var effect1507Statuses = []int{
|
||
int(info.PetStatus.Burned),
|
||
int(info.PetStatus.Frozen),
|
||
int(info.PetStatus.Poisoned),
|
||
int(info.PetStatus.Paralysis),
|
||
int(info.PetStatus.Fear),
|
||
int(info.PetStatus.Sleep),
|
||
}
|
||
|
||
func clearDarkSeed(target *input.Input) bool {
|
||
if target == nil {
|
||
return false
|
||
}
|
||
|
||
cleared := false
|
||
for _, eff := range target.Effects {
|
||
if eff == nil || !eff.Alive() {
|
||
continue
|
||
}
|
||
effID := eff.ID()
|
||
if effID.GetEffectType() != input.EffectType.Sub || int(effID.Suffix()) != 1501 {
|
||
continue
|
||
}
|
||
eff.Alive(false)
|
||
cleared = true
|
||
}
|
||
return cleared
|
||
}
|
||
|
||
func darkSeedStage(target *input.Input) int {
|
||
if target == nil {
|
||
return -1
|
||
}
|
||
|
||
eff := target.GetEffect(input.EffectType.Sub, 1501)
|
||
if eff == nil || !eff.Alive() {
|
||
return -1
|
||
}
|
||
|
||
darkSeed, ok := eff.(*Effect1501Sub)
|
||
if !ok {
|
||
return -1
|
||
}
|
||
return darkSeed.stage
|
||
}
|
||
|
||
func hasDragonType(target *input.Input) bool {
|
||
if target == nil || target.CurrentPet == nil {
|
||
return false
|
||
}
|
||
|
||
petType := target.CurrentPet.GetType()
|
||
if petType == nil {
|
||
return false
|
||
}
|
||
if petType.Primary == element.ElementTypeDragon {
|
||
return true
|
||
}
|
||
return petType.Secondary != nil && *petType.Secondary == element.ElementTypeDragon
|
||
}
|
||
|
||
func applyRandomStatuses1507(owner, target *input.Input, count int) bool {
|
||
if owner == nil || target == nil || count <= 0 {
|
||
return false
|
||
}
|
||
if count > len(effect1507Statuses) {
|
||
count = len(effect1507Statuses)
|
||
}
|
||
|
||
triggered := false
|
||
indexes := grand.Perm(len(effect1507Statuses))
|
||
for _, idx := range indexes[:count] {
|
||
statusEffect := owner.InitEffect(input.EffectType.Status, effect1507Statuses[idx])
|
||
if statusEffect == nil {
|
||
continue
|
||
}
|
||
before := len(target.Effects)
|
||
target.AddEffect(owner, statusEffect)
|
||
if len(target.Effects) > before {
|
||
triggered = true
|
||
}
|
||
}
|
||
return triggered
|
||
}
|
||
|
||
// Effect 1503: 清除对手身上的黑暗之种,清除成功则令对手随机受到1-500点固定伤害
|
||
type Effect1503 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1503) Skill_Use() bool {
|
||
if !clearDarkSeed(e.Ctx().Opp) {
|
||
return true
|
||
}
|
||
|
||
damage := alpacadecimal.NewFromInt(int64(grand.Intn(500) + 1))
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: damage,
|
||
})
|
||
return true
|
||
}
|
||
|
||
// Effect 1504: 40%令对手诅咒,若对手身上存在黑暗之种则概率翻倍
|
||
type Effect1504 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1504) Skill_Use() bool {
|
||
chance := 40
|
||
if hasDarkSeed(e.Ctx().Opp) {
|
||
chance *= 2
|
||
}
|
||
if chance > 100 {
|
||
chance = 100
|
||
}
|
||
|
||
success, _, _ := e.Input.Player.Roll(chance, 100)
|
||
if !success {
|
||
return true
|
||
}
|
||
|
||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(petStatusCurse))
|
||
if statusEffect != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1505: 黑暗之种成长期时附加200点固定伤害,黑暗之种长大后固定伤害翻倍
|
||
type Effect1505 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1505) Skill_Use() bool {
|
||
stage := darkSeedStage(e.Ctx().Opp)
|
||
if stage < 0 {
|
||
return true
|
||
}
|
||
|
||
damage := int64(200)
|
||
if stage >= 4 {
|
||
damage *= 2
|
||
}
|
||
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: alpacadecimal.NewFromInt(damage),
|
||
})
|
||
return true
|
||
}
|
||
|
||
// Effect 1506: 若对手不是龙系精灵则恢复自身{0}点体力
|
||
type Effect1506 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1506) Skill_Use() bool {
|
||
if len(e.Args()) == 0 || hasDragonType(e.Ctx().Opp) {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Args()[0])
|
||
return true
|
||
}
|
||
|
||
// Effect 1507: {0}回合内自身受到攻击则令对手随机进入{1}种异常状态,未触发则消除对手回合类效果
|
||
type Effect1507 struct {
|
||
RoundEffectArg0Base
|
||
triggered bool
|
||
}
|
||
|
||
func (e *Effect1507) Skill_Use_ex() bool {
|
||
if len(e.Args()) < 2 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
if applyRandomStatuses1507(e.Ctx().Our, e.Ctx().Opp, int(e.Args()[1].IntPart())) {
|
||
e.triggered = true
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1507) TurnEnd() {
|
||
if !e.triggered && e.Duration() == 1 {
|
||
e.Ctx().Opp.CancelTurn(e.Ctx().Our)
|
||
}
|
||
e.EffectNode.TurnEnd()
|
||
}
|
||
|
||
func init() {
|
||
curse := &BaseStatus{}
|
||
curse.Status = petStatusCurse
|
||
input.InitEffect(input.EffectType.Status, int(petStatusCurse), curse)
|
||
|
||
input.InitEffect(input.EffectType.Skill, 1503, &Effect1503{})
|
||
input.InitEffect(input.EffectType.Skill, 1504, &Effect1504{})
|
||
input.InitEffect(input.EffectType.Skill, 1505, &Effect1505{})
|
||
input.InitEffect(input.EffectType.Skill, 1506, &Effect1506{})
|
||
input.InitEffect(input.EffectType.Skill, 1507, &Effect1507{})
|
||
}
|