refactor: 重构战斗效果实现到独立文件
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
31
logic/service/fight/effect/157.go
Normal file
31
logic/service/fight/effect/157.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// 157 - n回合内,若受到攻击对手防御等级-1、特防等级-1、命中等级-1
|
||||
type Effect157 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect157) Skill_Use_ex() bool {
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
e.Ctx().Opp.SetProp(e.Ctx().Our, 1, -1, info.AbilityOpType.SUB)
|
||||
e.Ctx().Opp.SetProp(e.Ctx().Our, 3, -1, info.AbilityOpType.SUB)
|
||||
e.Ctx().Opp.SetProp(e.Ctx().Our, 5, -1, info.AbilityOpType.SUB)
|
||||
|
||||
return true
|
||||
}
|
||||
func (e *Effect157) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 157, &Effect157{})
|
||||
|
||||
}
|
||||
35
logic/service/fight/effect/166.go
Normal file
35
logic/service/fight/effect/166.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// 166 - n回合内,若对手使用属性攻击则m%对手XX等级k
|
||||
type Effect166 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect166) Skill_Use_ex() bool {
|
||||
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
chance := e.Args()[0].IntPart() // m%
|
||||
success, _, _ := e.Input.Player.Roll(int(chance), 100)
|
||||
if success {
|
||||
effectType := int8(e.Args()[1].IntPart()) // XX类型
|
||||
effectValue := int8(e.Args()[2].IntPart()) // 等级k
|
||||
e.Ctx().Opp.SetProp(e.Ctx().Our, effectType, effectValue, info.AbilityOpType.SUB)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect166) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 166, &Effect166{})
|
||||
|
||||
}
|
||||
35
logic/service/fight/effect/427.go
Normal file
35
logic/service/fight/effect/427.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// 427 - n回合内每次直接攻击都会使对手防御和特防m
|
||||
type Effect427 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect427) SkillUseed() bool {
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() != info.Category.STATUS {
|
||||
// 降低对手防御
|
||||
e.Ctx().Opp.SetProp(e.Ctx().Opp, 1, int8(e.SideEffectArgs[1]), info.AbilityOpType.SUB)
|
||||
|
||||
e.Ctx().Opp.SetProp(e.Ctx().Opp, 3, int8(e.SideEffectArgs[1]), info.AbilityOpType.SUB)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect427) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 427, &Effect427{})
|
||||
|
||||
}
|
||||
38
logic/service/fight/effect/443.go
Normal file
38
logic/service/fight/effect/443.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// 443 - n回合内若受到的伤害超过m,则对手疲惫x回合
|
||||
type Effect443 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect443) Skill_Use_ex() bool {
|
||||
damageThreshold := alpacadecimal.NewFromInt(int64(e.Args()[1].IntPart()))
|
||||
|
||||
if e.Ctx().Our.SumDamage.Cmp(damageThreshold) > 0 {
|
||||
// 对手疲惫x回合
|
||||
tiredEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Tired))
|
||||
if tiredEffect != nil {
|
||||
tiredEffect.Duration(int(e.Args()[2].IntPart())) // x回合
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, tiredEffect)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect443) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 443, &Effect443{})
|
||||
|
||||
}
|
||||
27
logic/service/fight/effect/561.go
Normal file
27
logic/service/fight/effect/561.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// 561 - 先出手时当回合对手使用技能后若自身体力为0,则令自身体力等于最大体力
|
||||
type Effect561 struct {
|
||||
node.EffectNode
|
||||
can bool
|
||||
}
|
||||
|
||||
func (e *Effect561) ActionEndEx() bool {
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) {
|
||||
if e.Ctx().Our.CurrentPet.GetHP().IntPart() == 0 {
|
||||
e.Ctx().Our.CurrentPet.Info.Hp = e.Ctx().Our.CurrentPet.Info.MaxHp
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 561, &Effect561{})
|
||||
|
||||
}
|
||||
@@ -900,36 +900,6 @@ func (e *Effect471) OnSkill() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 427 - n回合内每次直接攻击都会使对手防御和特防m
|
||||
type Effect427 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect427) SkillHit_ex() bool {
|
||||
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() != info.Category.STATUS {
|
||||
// 降低对手防御
|
||||
defDownEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.DefDown))
|
||||
if defDownEffect != nil {
|
||||
defDownEffect.SetArgs(e.Ctx().Our, int(e.Args()[1].IntPart())) // m
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, defDownEffect)
|
||||
}
|
||||
|
||||
// 降低对手特防
|
||||
spDefDownEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.SpDefDown))
|
||||
if spDefDownEffect != nil {
|
||||
spDefDownEffect.SetArgs(e.Ctx().Our, int(e.Args()[1].IntPart())) // m
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, spDefDownEffect)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect427) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||||
}
|
||||
|
||||
// 150 - n回合内,对手每回合防御和特防等级m
|
||||
type Effect150 struct {
|
||||
node.EffectNode
|
||||
@@ -1036,20 +1006,6 @@ func (e *Effect170) OnSkill() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 561 - 先出手时当回合对手使用技能后若自身体力为0,则令自身体力等于最大体力
|
||||
type Effect561 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect561) OnSkill() bool {
|
||||
if e.Ctx().Our.Speed > e.Ctx().Opp.Speed { // 先出手
|
||||
// 设置一个标志,用于在回合结束时检查
|
||||
e.Ctx().Our.ActivateReviveIfFaint = true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 425 - 随机使对手n项属性m,并将该属性附加给自己
|
||||
type Effect425 struct {
|
||||
node.EffectNode
|
||||
@@ -1154,70 +1110,6 @@ func (e *Effect497) SetArgs(t *input.Input, a ...int) {
|
||||
e.maxExtraDamage = a[2] // 最高k点
|
||||
}
|
||||
|
||||
// 443 - n回合内若受到的伤害超过m,则对手疲惫x回合
|
||||
type Effect443 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect443) Skill_Use_ex() bool {
|
||||
damageThreshold := alpacadecimal.NewFromInt(int64(e.Args()[1].IntPart()))
|
||||
|
||||
if e.Ctx().Our.SumDamage.Cmp(damageThreshold) > 0 {
|
||||
// 对手疲惫x回合
|
||||
tiredEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Tired))
|
||||
if tiredEffect != nil {
|
||||
tiredEffect.Duration(int(e.Args()[2].IntPart())) // x回合
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, tiredEffect)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect443) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||||
}
|
||||
|
||||
// 157 - n回合内,若受到攻击对手防御等级-1、特防等级-1、命中等级-1
|
||||
type Effect157 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect157) Skill_Use_ex() bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
|
||||
// 降低对手防御等级
|
||||
defDownEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.DefDown))
|
||||
if defDownEffect != nil {
|
||||
defDownEffect.SetArgs(e.Ctx().Our, 1) // 降低1级
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, defDownEffect)
|
||||
}
|
||||
|
||||
// 降低对手特防等级
|
||||
spDefDownEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.SpDefDown))
|
||||
if spDefDownEffect != nil {
|
||||
spDefDownEffect.SetArgs(e.Ctx().Our, 1) // 降低1级
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, spDefDownEffect)
|
||||
}
|
||||
|
||||
// 降低对手命中等级
|
||||
accuracyDownEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.AccuracyDown))
|
||||
if accuracyDownEffect != nil {
|
||||
accuracyDownEffect.SetArgs(e.Ctx().Our, 1) // 降低1级
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, accuracyDownEffect)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect157) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||||
}
|
||||
|
||||
// 412 - 若自身体力小于1/n,则每次攻击不消耗PP值
|
||||
type Effect412 struct {
|
||||
node.EffectNode
|
||||
@@ -1345,32 +1237,3 @@ func (e *Effect493) SetArgs(t *input.Input, a ...int) {
|
||||
e.critDuration = a[1] // n回合
|
||||
e.EffectNode.Duration(a[0]) // 持续m回合
|
||||
}
|
||||
|
||||
// 166 - n回合内,若对手使用属性攻击则m%对手XX等级k
|
||||
type Effect166 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect166) Skill_Use_ex() bool {
|
||||
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
chance := e.Args()[0].IntPart() // m%
|
||||
success, _, _ := e.Input.Player.Roll(int(chance), 100)
|
||||
if success {
|
||||
effectType := int(e.Args()[1].IntPart()) // XX类型
|
||||
effectValue := int(e.Args()[2].IntPart()) // 等级k
|
||||
|
||||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, effectType)
|
||||
if statusEffect != nil {
|
||||
statusEffect.SetArgs(e.Ctx().Our, effectValue)
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect166) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.EffectNode.Duration(a[0]) // 持续n回合
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user