feat(fight): 添加新效果类型574并优化现有战斗逻辑 - 重命名NewSel409结构体的Action_end_ex方法为Skill_Use_ex - 将effect/523中HP检查改为Alive()方法调用 - 修复selfkill效果中的代码格式问题 - 新增效果类型574:消耗自身全部体力使下次技能必定先手、命中且暴击 - 实现Effect574的ComparePre和ActionStart方法处理先手、命中和暴击逻辑 ```
275 lines
5.4 KiB
Go
275 lines
5.4 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"
|
||
)
|
||
|
||
type SelfKill struct {
|
||
node.EffectNode
|
||
can bool
|
||
}
|
||
|
||
func (e *SelfKill) SetArgs(t *input.Input, a ...int) {
|
||
|
||
//e.CanStack(-1)//后续的不会顶掉这个效果
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1) //次数类,无限回合
|
||
|
||
}
|
||
func (e *SelfKill) OnSkill() bool {
|
||
if e.can {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
|
||
})
|
||
e.can = true
|
||
|
||
return true
|
||
}
|
||
|
||
// 自杀,所以效果不消除
|
||
func (e *SelfKill) SwitchOut(in *input.Input) bool {
|
||
return true
|
||
}
|
||
|
||
/**
|
||
* 消耗自身全部体力(体力降到0), 使下一只出战精灵的 battle_lv1 和 battle_lv2 能力提升1个等级
|
||
*/
|
||
type Effect59 struct {
|
||
SelfKill
|
||
}
|
||
|
||
func init() {
|
||
|
||
input.InitEffect(input.EffectType.Skill, 59, &Effect59{})
|
||
|
||
}
|
||
|
||
func (e *Effect59) TurnStart(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
|
||
if !e.can {
|
||
return
|
||
}
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[0].IntPart()), 1)
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[1].IntPart()), 1)
|
||
e.Alive(false)
|
||
return
|
||
}
|
||
|
||
func init() {
|
||
|
||
input.InitEffect(input.EffectType.Skill, 71, &Effect71{
|
||
count: 2,
|
||
})
|
||
|
||
}
|
||
|
||
/**
|
||
* 自己牺牲(体力降到0), 使下一只出战精灵在前两回合内必定致命一击
|
||
*/
|
||
type Effect71 struct {
|
||
SelfKill
|
||
count int
|
||
}
|
||
|
||
func (e *Effect71) ActionStart(a, b *action.SelectSkillAction) bool {
|
||
if !e.can {
|
||
return true
|
||
}
|
||
//fmt.Println(e.Ctx().SkillEntity)
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().SkillEntity.XML.CritRate = 16
|
||
e.count--
|
||
if e.count <= 0 {
|
||
e.Alive(false)
|
||
|
||
}
|
||
return true
|
||
}
|
||
func init() {
|
||
|
||
input.InitEffect(input.EffectType.Skill, 144, &Effect144{})
|
||
|
||
}
|
||
|
||
// 144 - 消耗自己所有体力,使下一个出战的精灵n回合免疫异常状态
|
||
type Effect144 struct {
|
||
SelfKill
|
||
count int
|
||
}
|
||
|
||
func (e *Effect144) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||
|
||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||
if !e.can {
|
||
return true
|
||
}
|
||
|
||
if int(e.Input.FightC.GetOverInfo().Round) >= e.count+e.SideEffectArgs[0] {
|
||
e.Alive(false)
|
||
}
|
||
if e.count == 0 { //记录开始回合
|
||
e.count = int(e.Input.FightC.GetOverInfo().Round)
|
||
}
|
||
|
||
if in != e.Ctx().Opp {
|
||
return true
|
||
}
|
||
if input.IS_Stat(effEffect) {
|
||
return false
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
// 435 - 牺牲自己,使下回合出场的精灵首次攻击必定命中,必定先手
|
||
type Effect435 struct {
|
||
SelfKill
|
||
}
|
||
|
||
func (e *Effect435) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
|
||
if !e.can {
|
||
return true
|
||
}
|
||
if fattack == nil {
|
||
return true
|
||
}
|
||
//先手是自己
|
||
if fattack.PlayerID == e.Ctx().Our.UserID {
|
||
return true
|
||
}
|
||
if sattack == nil {
|
||
return true
|
||
}
|
||
if sattack == nil {
|
||
return true
|
||
}
|
||
if sattack.SkillEntity == nil {
|
||
return true
|
||
}
|
||
//对调
|
||
sattack.SkillEntity.XML.Priority += 7
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
func (e *Effect435) ActionStart(a, b *action.SelectSkillAction) bool {
|
||
|
||
if !e.can {
|
||
return true
|
||
}
|
||
//fmt.Println(e.Ctx().SkillEntity)
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
e.Ctx().SkillEntity.XML.MustHit = 1
|
||
return true
|
||
}
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 435, &Effect435{})
|
||
|
||
}
|
||
|
||
/**
|
||
* 牺牲全部体力造成对手250~300点伤害,造成致命伤害时,对手剩下1点体力
|
||
*/
|
||
type Effect112 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func init() {
|
||
|
||
input.InitEffect(input.EffectType.Skill, 112, &Effect112{})
|
||
|
||
}
|
||
|
||
// 命中之后
|
||
func (e *Effect112) Skill_Use() bool {
|
||
|
||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
|
||
})
|
||
n := int64(e.Input.FightC.GetRand().Int31n(int32(50+1))) + 250
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: alpacadecimal.Min(alpacadecimal.NewFromInt(n), e.Ctx().Opp.CurrentPet.GetHP().Sub(alpacadecimal.NewFromInt(1))),
|
||
})
|
||
|
||
return true
|
||
}
|
||
|
||
// {
|
||
// "id": 574,
|
||
// "argsNum": 0,
|
||
// "info": "消耗自身全部体力,令己方下次使用的技能必定先手、必定命中,下次命中的攻击技能必定打出致命一击"
|
||
// },
|
||
//
|
||
|
||
type Effect574 struct {
|
||
SelfKill
|
||
}
|
||
|
||
func (e *Effect574) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
|
||
if !e.can {
|
||
return true
|
||
}
|
||
if fattack == nil {
|
||
return true
|
||
}
|
||
//先手是自己
|
||
if fattack.PlayerID == e.Ctx().Our.UserID {
|
||
return true
|
||
}
|
||
if sattack == nil {
|
||
return true
|
||
}
|
||
if sattack == nil {
|
||
return true
|
||
}
|
||
if sattack.SkillEntity == nil {
|
||
return true
|
||
}
|
||
//对调
|
||
sattack.SkillEntity.XML.Priority += 7
|
||
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
func (e *Effect574) ActionStart(a, b *action.SelectSkillAction) bool {
|
||
|
||
if !e.can {
|
||
return true
|
||
}
|
||
//fmt.Println(e.Ctx().SkillEntity)
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
e.Ctx().SkillEntity.XML.MustHit = 1
|
||
e.Ctx().SkillEntity.XML.CritRate = 16
|
||
|
||
return true
|
||
}
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 574, &Effect574{})
|
||
|
||
}
|