139 lines
3.4 KiB
Go
139 lines
3.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"
|
||
"github.com/gogf/gf/v2/util/grand"
|
||
)
|
||
|
||
// Effect 119: 若伤害为奇数,30%对手疲惫1回合;若为偶数,30%速度+1
|
||
type Effect119 struct {
|
||
FixedDuration1Base
|
||
can bool
|
||
}
|
||
|
||
func (e *Effect119) Skill_Use() bool {
|
||
|
||
e.can = true
|
||
return true
|
||
}
|
||
|
||
func (e *Effect119) DamageLock(damageValue *info.DamageZone) bool {
|
||
if !e.can {
|
||
return true
|
||
}
|
||
|
||
isOdd := damageValue.Damage.IntPart()%2 == 1
|
||
|
||
if isOdd {
|
||
// 奇数:30%对手疲惫1回合
|
||
ok, _, _ := e.Input.Player.Roll(30, 100)
|
||
if ok {
|
||
eff := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Tired))
|
||
if eff == nil {
|
||
return true
|
||
}
|
||
eff.Duration(1)
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
|
||
}
|
||
} else {
|
||
// 偶数:30%速度+1
|
||
ok, _, _ := e.Input.Player.Roll(30, 100)
|
||
if ok {
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, 4, 1)
|
||
}
|
||
}
|
||
e.can = false
|
||
return true
|
||
}
|
||
|
||
// Effect 120: 50%概率对方减血1/{0},50%概率自己减血1/{0}
|
||
type Effect120 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect120) Skill_Use() bool {
|
||
|
||
// 50%概率
|
||
ok, _, _ := e.Input.Player.Roll(50, 100)
|
||
|
||
denominator := int(e.Args()[0].IntPart())
|
||
percent := alpacadecimal.NewFromInt(100).Div(alpacadecimal.NewFromInt(int64(denominator)))
|
||
|
||
if ok {
|
||
// 对方减血1/{0}
|
||
oppMaxHP := alpacadecimal.NewFromInt(int64(e.Ctx().Opp.CurPet[0].Info.MaxHp))
|
||
damage := oppMaxHP.Mul(percent).Div(alpacadecimal.NewFromInt(100))
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: damage,
|
||
})
|
||
} else {
|
||
// 自己减血1/{0}
|
||
ourMaxHP := alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurPet[0].Info.MaxHp))
|
||
damage := ourMaxHP.Mul(percent).Div(alpacadecimal.NewFromInt(100))
|
||
e.Ctx().Our.Damage(e.Ctx().Opp, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: damage,
|
||
})
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 121: 属性相同时,{0}%概率让对方麻痹
|
||
type Effect121 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect121) Skill_Use() bool {
|
||
|
||
// 检查属性是否相同
|
||
if e.Ctx().Our.CurPet[0].PetInfo.Type == e.Ctx().Opp.CurPet[0].PetInfo.Type {
|
||
chance := int(e.Args()[0].IntPart())
|
||
ok, _, _ := e.Input.Player.Roll(chance, 100)
|
||
if ok {
|
||
eff := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Paralysis))
|
||
if eff == nil {
|
||
return true
|
||
}
|
||
eff.Duration(grand.N(1, 2))
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 123: {0}回合内受到任何伤害,自身{1}提高{2}个等级
|
||
type Effect123 struct {
|
||
RoundEffectSideArg0Base
|
||
can bool
|
||
}
|
||
|
||
func (e *Effect123) TurnStart(at, de *action.SelectSkillAction) {
|
||
e.can = true
|
||
}
|
||
|
||
func (e *Effect123) Be_Damage(at, _ alpacadecimal.Decimal) {
|
||
if e.can {
|
||
propIndex := int(e.Args()[1].IntPart())
|
||
changeAmount := int(e.Args()[2].IntPart())
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(propIndex), int8(changeAmount))
|
||
e.can = false
|
||
}
|
||
}
|
||
|
||
// -----------------------------------------------------------
|
||
// 初始化
|
||
// -----------------------------------------------------------
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 119, &Effect119{})
|
||
input.InitEffect(input.EffectType.Skill, 120, &Effect120{})
|
||
input.InitEffect(input.EffectType.Skill, 121, &Effect121{})
|
||
|
||
input.InitEffect(input.EffectType.Skill, 123, &Effect123{})
|
||
}
|