refactor(effect): 移除未使用的element导入并优化自然敌人判断逻辑 移除了NewSeIdx_14.go中未使用的element包导入,将自然敌人判断逻辑 提取到EffectNode基类中,通过ISNaturalEnemy方法统一处理。 ```
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
element "blazing/common/data/Element"
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
@@ -16,17 +15,10 @@ type NewSel14 struct {
|
||||
|
||||
func (e *NewSel14) TurnStart(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
|
||||
// TODO: 实现若遇到天敌, 则战斗开始时连续害怕 n 回合;(a1: n)的核心逻辑
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return
|
||||
}
|
||||
t, _ := element.Calculator.GetOffensiveMultiplier(e.Ctx().Opp.CurrentPet.Type, e.Ctx().Our.CurrentPet.Type)
|
||||
// evs := gconv.Uint32s(strings.Split(xmlres.PetMAP[int(e.Ctx().Our.CurrentPet.ID)].NaturalEnemy, " "))
|
||||
// _, ok := lo.Find(evs, func(t uint32) bool {
|
||||
// return t == uint32(e.Ctx().Opp.CurrentPet.ID)
|
||||
// })
|
||||
if t <= 1 {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime || !e.ISNaturalEnemy() {
|
||||
return
|
||||
}
|
||||
|
||||
// 5. 获取状态效果实例并设置参数
|
||||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Fear))
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// 497 - 附加m点固定伤害,每次使用额外附加n点,最高k点,遇到天敌时效果翻倍
|
||||
type Effect497 struct {
|
||||
node.EffectNode
|
||||
Skillid int //记录使用的技能 ,如果技能变了就删除effect
|
||||
UseSkillCount int //技能使用了多少次,切换后置0
|
||||
}
|
||||
|
||||
func (e *Effect497) OnSkill() bool {
|
||||
if e.Skillid != 0 && e.Ctx().SkillEntity.ID != e.Skillid {
|
||||
e.Alive(false)
|
||||
e.UseSkillCount = 0
|
||||
return true
|
||||
|
||||
}
|
||||
e.Skillid = e.Ctx().SkillEntity.ID
|
||||
add := e.EffectNode.SideEffectArgs[0] + e.EffectNode.SideEffectArgs[1]*e.UseSkillCount
|
||||
add = utils.Min(add, e.EffectNode.SideEffectArgs[2])
|
||||
// 附加固定伤害
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: alpacadecimal.NewFromInt(int64(add)),
|
||||
}
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func init() {
|
||||
t := &Effect497{}
|
||||
t.Duration(-1) //次数类无限回合
|
||||
t.CanStack(true) //后续的不会顶掉这个效果
|
||||
input.InitEffect(input.EffectType.Skill, 497, t)
|
||||
|
||||
}
|
||||
192
logic/service/fight/effect/addlevel.go
Normal file
192
logic/service/fight/effect/addlevel.go
Normal file
@@ -0,0 +1,192 @@
|
||||
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"
|
||||
)
|
||||
|
||||
/**
|
||||
* 连续使用每次威力增加n,最高威力m
|
||||
*/
|
||||
|
||||
type AddLvelEffect struct {
|
||||
node.EffectNode
|
||||
Skillid int //记录使用的技能 ,如果技能变了就删除effect
|
||||
UseSkillCount int64 //技能使用了多少次,切换后置0
|
||||
|
||||
}
|
||||
|
||||
// 使用技能
|
||||
func (e *AddLvelEffect) SkillHit() bool {
|
||||
|
||||
if (e.Skillid != 0 && e.Ctx().SkillEntity.ID != e.Skillid) || e.Ctx().SkillEntity.AttackTime == 0 {
|
||||
e.Alive(false)
|
||||
e.UseSkillCount = 0
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
e.Duration(-1) //次数类无限回合
|
||||
e.CanStack(true) //后续的不会顶掉这个效果
|
||||
e.Skillid = e.Ctx().SkillEntity.ID
|
||||
e.UseSkillCount++
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *AddLvelEffect) GetADD(base, add, max alpacadecimal.Decimal) alpacadecimal.Decimal {
|
||||
|
||||
return alpacadecimal.Min(add.Mul(alpacadecimal.NewFromInt(e.UseSkillCount)), max)
|
||||
|
||||
}
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 9, &Effect9{})
|
||||
|
||||
}
|
||||
|
||||
type Effect9 struct {
|
||||
AddLvelEffect
|
||||
}
|
||||
|
||||
func (e *Effect9) SkillHit() bool {
|
||||
|
||||
e.Ctx().SkillEntity.Power += int(e.GetADD(alpacadecimal.Zero, e.Args()[0], e.Args()[1]).IntPart())
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.NewSel, 484, &Effect484{})
|
||||
}
|
||||
|
||||
// 484 - 连击n次,每次命中后连击数+m,最高连击p次
|
||||
type Effect484 struct {
|
||||
AddLvelEffect
|
||||
}
|
||||
|
||||
func (e *Effect484) Damage_Mul(t *info.DamageZone) bool {
|
||||
if t.Type != info.DamageType.Red {
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
t.Damage = t.Damage.Mul(e.GetADD(e.Args()[0], e.Args()[1], e.Args()[2]))
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 411 - 附加对手当前体力值n%的百分比伤害,连续使用每次增加m%,最高k%
|
||||
type Effect411 struct {
|
||||
AddLvelEffect
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.NewSel, 411, &Effect411{})
|
||||
}
|
||||
func (e *Effect411) Skill_Use() bool {
|
||||
|
||||
// 附加百分比伤害
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Percent,
|
||||
Damage: e.Ctx().Opp.CurrentPet.GetHP().Mul(e.GetADD(e.Args()[0], e.Args()[1], e.Args()[2]).Mul(alpacadecimal.NewFromInt(100))),
|
||||
}
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.NewSel, 497, &Effect429{
|
||||
ispower: true,
|
||||
})
|
||||
input.InitEffect(input.EffectType.NewSel, 497, &Effect429{})
|
||||
}
|
||||
|
||||
// 497 - 附加m点固定伤害,每次使用额外附加n点,最高k点,遇到天敌时效果翻倍
|
||||
|
||||
// 429 - 附加m点固定伤害,连续使用每次增加n点固定伤害,最高附加k点固定伤害
|
||||
type Effect429 struct {
|
||||
AddLvelEffect
|
||||
ispower bool
|
||||
}
|
||||
|
||||
func (e *Effect429) Skill_Use() bool {
|
||||
|
||||
// 附加固定伤害
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: e.GetADD(e.Args()[0], e.Args()[1], e.Args()[2]),
|
||||
}
|
||||
if e.ISNaturalEnemy() && e.ispower {
|
||||
damageZone.Damage.Mul(alpacadecimal.NewFromInt(2))
|
||||
}
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.NewSel, 181, &Effect181{})
|
||||
}
|
||||
|
||||
// 181 - n%几率令对手XX,连续攻击每次提高m%几率最高提高k%
|
||||
type Effect181 struct {
|
||||
AddLvelEffect
|
||||
}
|
||||
|
||||
func (e *Effect181) Skill_Use() bool {
|
||||
|
||||
success, _, _ := e.Input.Player.Roll(int(e.GetADD(e.Args()[0], e.Args()[2], e.Args()[3]).IntPart()), 100)
|
||||
if success {
|
||||
// 添加异常状态
|
||||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[1].IntPart())) // 以麻痹为例
|
||||
if statusEffect != nil {
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 441 - 每次攻击提升n%的致命几率,最高提升m%
|
||||
type Effect441 struct {
|
||||
AddLvelEffect
|
||||
}
|
||||
|
||||
func (e *Effect441) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
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.CritRate += int(e.GetADD(alpacadecimal.Zero, e.Args()[2], e.Args()[3]).IntPart())
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 465 - m%令对手疲惫n回合,每次使用几率提升x%,最高y%
|
||||
type Effect465 struct {
|
||||
AddLvelEffect
|
||||
}
|
||||
|
||||
func (e *Effect465) Skill_Use() bool {
|
||||
|
||||
success, _, _ := e.Input.Player.Roll(int(e.GetADD(e.Args()[0], e.Args()[2], e.Args()[3]).IntPart()), 100)
|
||||
if success {
|
||||
// 添加异常状态
|
||||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Tired)) // 以麻痹为例
|
||||
if statusEffect != nil {
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -9,74 +9,6 @@ import (
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// 181 - n%几率令对手XX,连续攻击每次提高m%几率最高提高k%
|
||||
type Effect181 struct {
|
||||
node.EffectNode
|
||||
increaseChance int
|
||||
maxChance int
|
||||
currentChance int
|
||||
}
|
||||
|
||||
func (e *Effect181) OnSkill() bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
|
||||
baseChance := e.Args()[0].IntPart()
|
||||
e.currentChance = int(baseChance) + e.increaseChance
|
||||
|
||||
if e.currentChance > e.maxChance {
|
||||
e.currentChance = e.maxChance
|
||||
}
|
||||
|
||||
success, _, _ := e.Input.Player.Roll(e.currentChance, 100)
|
||||
if success {
|
||||
// 添加异常状态
|
||||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Paralysis)) // 以麻痹为例
|
||||
if statusEffect != nil {
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||||
}
|
||||
}
|
||||
|
||||
// 增加下次攻击的触发几率
|
||||
e.increaseChance += int(e.Args()[1].IntPart())
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect181) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.maxChance = a[2] // 最大几率
|
||||
}
|
||||
|
||||
// 441 - 每次攻击提升n%的致命几率,最高提升m%
|
||||
type Effect441 struct {
|
||||
node.EffectNode
|
||||
totalCritIncrease int
|
||||
maxCritIncrease int
|
||||
}
|
||||
|
||||
func (e *Effect441) SkillHit() bool {
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
currentCrit := e.Ctx().Our.CurrentPet.CritRate
|
||||
increase := int(e.Args()[0].IntPart())
|
||||
|
||||
if e.totalCritIncrease+increase <= e.maxCritIncrease {
|
||||
e.totalCritIncrease += increase
|
||||
e.Ctx().Our.CurrentPet.CritRate = currentCrit + increase
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect441) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.maxCritIncrease = a[1]
|
||||
}
|
||||
|
||||
// 165 - n回合内,每回合防御和特防等级+m
|
||||
type Effect165 struct {
|
||||
node.EffectNode
|
||||
@@ -454,45 +386,6 @@ func (e *Effect430) OnSkill() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 465 - m%令对手疲惫n回合,每次使用几率提升x%,最高y%
|
||||
type Effect465 struct {
|
||||
node.EffectNode
|
||||
accumulatedChance int
|
||||
maxChance int
|
||||
incrementPerUse int
|
||||
}
|
||||
|
||||
func (e *Effect465) OnSkill() bool {
|
||||
chance := int(e.Args()[0].IntPart()) + e.accumulatedChance
|
||||
if chance > e.maxChance {
|
||||
chance = e.maxChance
|
||||
}
|
||||
|
||||
success, _, _ := e.Input.Player.Roll(chance, 100)
|
||||
if success {
|
||||
// 令对手疲惫n回合
|
||||
tiredEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Tired))
|
||||
if tiredEffect != nil {
|
||||
tiredEffect.Duration(int(e.Args()[1].IntPart()))
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, tiredEffect)
|
||||
}
|
||||
}
|
||||
|
||||
// 增加下次使用的几率
|
||||
e.accumulatedChance += e.incrementPerUse
|
||||
if e.accumulatedChance > e.maxChance {
|
||||
e.accumulatedChance = e.maxChance
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect465) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.maxChance = a[2] // 最高y%
|
||||
e.incrementPerUse = a[3] // 每次使用几率提升x%
|
||||
}
|
||||
|
||||
// 501 - 若造成的伤害不足m,则对手XX等级-n
|
||||
type Effect501 struct {
|
||||
node.EffectNode
|
||||
@@ -626,26 +519,6 @@ func (e *Effect457) Skill_Use_ex() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 144 - 消耗自己所有体力,使下一个出战的精灵n回合免疫异常状态
|
||||
type Effect144 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect144) OnSkill() bool {
|
||||
// 消耗所有体力
|
||||
e.Ctx().Our.CurrentPet.Info.Hp = 0
|
||||
e.Ctx().Our.CurrentPet.NotAlive = true
|
||||
|
||||
// 设置下一个出战精灵的免疫异常状态效果
|
||||
nextPetImmunityEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.ImmuneStatus))
|
||||
if nextPetImmunityEffect != nil {
|
||||
nextPetImmunityEffect.Duration(int(e.Args()[0].IntPart())) // n回合
|
||||
e.Ctx().Our.SetNextPetStatusImmunity(nextPetImmunityEffect)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 468 - 回合开始时,若自身处于能力下降状态,则威力翻倍,同时解除能力下降状态
|
||||
type Effect468 struct {
|
||||
node.EffectNode
|
||||
@@ -785,45 +658,6 @@ func (e *Effect486) OnSkill() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 429 - 附加m点固定伤害,连续使用每次增加n点固定伤害,最高附加k点固定伤害
|
||||
type Effect429 struct {
|
||||
node.EffectNode
|
||||
stackedDamage int
|
||||
maxDamage int
|
||||
incrementPerUse int
|
||||
}
|
||||
|
||||
func (e *Effect429) OnSkill() bool {
|
||||
// 计算附加伤害
|
||||
baseDamage := int(e.Args()[0].IntPart()) // m点固定伤害
|
||||
currentDamage := baseDamage + e.stackedDamage
|
||||
|
||||
if currentDamage > e.maxDamage {
|
||||
currentDamage = e.maxDamage
|
||||
}
|
||||
|
||||
// 附加固定伤害
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: alpacadecimal.NewFromInt(int64(currentDamage)),
|
||||
}
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
|
||||
|
||||
// 更新叠加伤害
|
||||
e.stackedDamage += e.incrementPerUse
|
||||
if e.stackedDamage > e.maxDamage-baseDamage {
|
||||
e.stackedDamage = e.maxDamage - baseDamage
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect429) SetArgs(t *input.Input, a ...int) {
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.maxDamage = a[2] // 最高k点
|
||||
e.incrementPerUse = a[1] // 每次增加n点
|
||||
}
|
||||
|
||||
// 471 - 先出手时n回合内免疫异常状态
|
||||
type Effect471 struct {
|
||||
node.EffectNode
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
func init() {
|
||||
t := &Effect411{}
|
||||
t.Duration(-1) //次数类无限回合
|
||||
t.CanStack(true) //后续的不会顶掉这个效果
|
||||
input.InitEffect(input.EffectType.Skill, 411, t)
|
||||
|
||||
}
|
||||
|
||||
// 411 - 附加对手当前体力值n%的百分比伤害,连续使用每次增加m%,最高k%
|
||||
type Effect411 struct {
|
||||
node.EffectNode
|
||||
Skillid int //记录使用的技能 ,如果技能变了就删除effect
|
||||
UseSkillCount int //技能使用了多少次,切换后置0
|
||||
}
|
||||
|
||||
func (e *Effect411) OnSkill() bool {
|
||||
if e.Skillid != 0 && e.Ctx().SkillEntity.ID != e.Skillid {
|
||||
e.Alive(false)
|
||||
e.UseSkillCount = 0
|
||||
return true
|
||||
|
||||
}
|
||||
e.Skillid = e.Ctx().SkillEntity.ID
|
||||
opponentHp := e.Ctx().Opp.CurrentPet.GetHP()
|
||||
|
||||
addhe := utils.Min(e.Args()[1].IntPart()*int64(e.UseSkillCount), e.Args()[2].IntPart())
|
||||
|
||||
// 附加百分比伤害
|
||||
damageZone := &info.DamageZone{
|
||||
Type: info.DamageType.Percent,
|
||||
Damage: opponentHp.Mul((e.Args()[0].Add(alpacadecimal.NewFromInt(addhe))).Mul(alpacadecimal.NewFromInt(100))),
|
||||
}
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, damageZone)
|
||||
|
||||
e.UseSkillCount++
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
// 484 - 连击n次,每次命中后连击数+m,最高连击p次
|
||||
type Effect484 struct {
|
||||
node.EffectNode
|
||||
count int64
|
||||
}
|
||||
|
||||
func (e *Effect484) Damage_Mul(t *info.DamageZone) bool {
|
||||
|
||||
if t.Type == info.DamageType.Red {
|
||||
n := utils.Min(e.Args()[0].IntPart()+e.count, e.Args()[1].IntPart())
|
||||
t.Damage = t.Damage.Mul(alpacadecimal.NewFromInt(int64(n)))
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
func (e *Effect484) SkillHit() bool {
|
||||
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
if e.Ctx().SkillEntity.AttackTime != 0 {
|
||||
e.count = 0
|
||||
return true
|
||||
}
|
||||
e.count += e.Args()[1].IntPart()
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.NewSel, 484, &Effect484{})
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
)
|
||||
|
||||
/**
|
||||
* 消耗自身全部体力(体力降到0), 使下一只出战精灵的 battle_lv1 和 battle_lv2 能力提升1个等级
|
||||
*/
|
||||
type Effect59 struct {
|
||||
node.EffectNode
|
||||
can bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 59, &Effect59{})
|
||||
|
||||
}
|
||||
func (e *Effect59) SetArgs(t *input.Input, a ...int) {
|
||||
|
||||
//e.CanStack(-1)//后续的不会顶掉这个效果
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(-1) //次数类,无限回合
|
||||
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
func (e *Effect59) OnSkill() bool {
|
||||
|
||||
e.can = 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.Ctx().Our.CurrentPet.NotAlive = true
|
||||
return true
|
||||
}
|
||||
func (e *Effect59) SwitchOut(in *input.Input) bool {
|
||||
return true
|
||||
}
|
||||
func (e *Effect59) SwitchIn(in *input.Input) bool {
|
||||
// 1. 检查效果是否生效(当次攻击有效)
|
||||
if !e.can {
|
||||
return true
|
||||
}
|
||||
//
|
||||
if in != e.Ctx().Our {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[0].IntPart()), 1, info.AbilityOpType.ADD)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[1].IntPart()), 1, info.AbilityOpType.ADD)
|
||||
e.Alive(false)
|
||||
return true
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
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"
|
||||
)
|
||||
|
||||
/**
|
||||
* 自己牺牲(体力降到0), 使下一只出战精灵在前两回合内必定致命一击
|
||||
*/
|
||||
type Effect71 struct {
|
||||
node.EffectNode
|
||||
count int
|
||||
can bool
|
||||
can2 bool
|
||||
}
|
||||
|
||||
func (e *Effect71) SwitchOut(in *input.Input) bool {
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 71, &Effect71{})
|
||||
|
||||
}
|
||||
func (e *Effect71) SetArgs(t *input.Input, a ...int) {
|
||||
|
||||
//e.CanStack(-1)//后续的不会顶掉这个效果
|
||||
e.EffectNode.SetArgs(t, a...)
|
||||
e.Duration(-1) //次数类,无限回合
|
||||
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
func (e *Effect71) OnSkill() bool {
|
||||
|
||||
e.can = 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.Ctx().Our.CurrentPet.NotAlive = true
|
||||
return true
|
||||
}
|
||||
func (e *Effect71) SwitchIn(in *input.Input) bool {
|
||||
// 1. 检查效果是否生效(当次攻击有效)
|
||||
if !e.can {
|
||||
return true
|
||||
}
|
||||
|
||||
if in != e.Ctx().Our {
|
||||
return true
|
||||
}
|
||||
e.can2 = true
|
||||
// t := &Effect71_sub{
|
||||
// count: 2,
|
||||
// }
|
||||
// t.Duration(-1)
|
||||
// tt := e.ID()
|
||||
// tt.SetEffectType(input.EffectType.Sub)
|
||||
|
||||
// t.ID(tt)
|
||||
// e.Ctx().Our.AddEffect(e.Ctx().Our, t)
|
||||
|
||||
// e.Alive(false)
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect71) ActionStart(a, b *action.SelectSkillAction) bool {
|
||||
if !e.can2 {
|
||||
return true
|
||||
}
|
||||
|
||||
//fmt.Println(e.Ctx().SkillEntity)
|
||||
if e.Ctx().SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||||
return true
|
||||
}
|
||||
if e.count <= 0 {
|
||||
e.Alive(false)
|
||||
}
|
||||
e.count--
|
||||
e.Ctx().SkillEntity.CritRate = 16
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
/**
|
||||
* 连续使用每次威力增加n,最高威力m
|
||||
*/
|
||||
|
||||
func init() {
|
||||
t := &Effect9{}
|
||||
t.Duration(-1) //次数类无限回合
|
||||
t.CanStack(true) //后续的不会顶掉这个效果
|
||||
input.InitEffect(input.EffectType.Skill, 9, t)
|
||||
|
||||
}
|
||||
|
||||
type Effect9 struct {
|
||||
node.EffectNode
|
||||
Skillid int //记录使用的技能 ,如果技能变了就删除effect
|
||||
UseSkillCount int //技能使用了多少次,切换后置0
|
||||
}
|
||||
|
||||
func (e *Effect9) SkillHit() bool {
|
||||
if e.Skillid != 0 && e.Ctx().SkillEntity.ID != e.Skillid {
|
||||
e.Alive(false)
|
||||
e.UseSkillCount = 0
|
||||
return true
|
||||
|
||||
}
|
||||
e.Skillid = e.Ctx().SkillEntity.ID
|
||||
add := e.EffectNode.SideEffectArgs[0] * e.UseSkillCount
|
||||
|
||||
e.Ctx().SkillEntity.Power += utils.Min(add, e.EffectNode.SideEffectArgs[1])
|
||||
|
||||
e.UseSkillCount++
|
||||
return true
|
||||
}
|
||||
145
logic/service/fight/effect/selfkill.go
Normal file
145
logic/service/fight/effect/selfkill.go
Normal file
@@ -0,0 +1,145 @@
|
||||
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.Ctx().Our.CurrentPet.NotAlive = true
|
||||
return true
|
||||
}
|
||||
|
||||
// 自杀,所以效果不消除
|
||||
func (e *SelfKill) SwitchOut(in *input.Input) bool {
|
||||
return true
|
||||
}
|
||||
func (e *Effect59) SwitchIn(in *input.Input) bool {
|
||||
// 1. 检查效果是否生效(当次攻击有效)
|
||||
|
||||
//
|
||||
if in != e.Ctx().Our {
|
||||
return true
|
||||
}
|
||||
e.can = true
|
||||
|
||||
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, info.AbilityOpType.ADD)
|
||||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(e.Args()[1].IntPart()), 1, info.AbilityOpType.ADD)
|
||||
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
|
||||
}
|
||||
if e.count <= 0 {
|
||||
e.Alive(false)
|
||||
}
|
||||
e.count--
|
||||
e.Ctx().SkillEntity.CritRate = 16
|
||||
|
||||
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
|
||||
}
|
||||
@@ -200,6 +200,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
} else {
|
||||
attacker, defender = f.Second, f.First
|
||||
originalSkill = f.copySkill(secondAttack)
|
||||
//取消后手历史效果
|
||||
f.Second.ReactvieEffect()
|
||||
}
|
||||
|
||||
@@ -214,28 +215,23 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
})
|
||||
|
||||
canUse := canUseSkill && action.CanUse(currentSkill) && attacker.CurrentPet.Info.Hp > 0
|
||||
if i == 0 { //先手方被控,这时候应该算做未出手状态
|
||||
if canUse {
|
||||
f.TrueFirst = attacker
|
||||
|
||||
} else {
|
||||
|
||||
f.TrueFirst = defender
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if !canUse {
|
||||
|
||||
attacker.RecoverEffect()
|
||||
currentSkill = nil
|
||||
if i == 0 {
|
||||
//不能使用,所以这时候取消后手
|
||||
defender.ReactvieEffect()
|
||||
firstAttack, secondAttack = secondAttack, firstAttack //互换先手权
|
||||
f.First, f.Second = f.Second, f.First
|
||||
//反转先后手
|
||||
originalSkill = f.copySkill(secondAttack)
|
||||
f.Second.ReactvieEffect()
|
||||
originalSkill = f.copySkill(firstAttack)
|
||||
|
||||
currentSkill = originalSkill
|
||||
attacker, defender = defender, attacker
|
||||
}
|
||||
|
||||
} else {
|
||||
f.processSkillAttack(attacker, defender, currentSkill)
|
||||
currentSkill = originalSkill //还原技能
|
||||
@@ -301,10 +297,6 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
})
|
||||
ff.GenInfo()
|
||||
})
|
||||
if f.TrueFirst != f.First {
|
||||
f.First, f.Second = f.Second, f.First
|
||||
|
||||
}
|
||||
|
||||
attackValueResult := info.AttackValueS{
|
||||
FAttack: *f.First.AttackValue,
|
||||
|
||||
@@ -37,10 +37,10 @@ type FightC struct {
|
||||
StartTime time.Time
|
||||
actionChan chan action.BattleActionI // 所有操作统一从这里进入
|
||||
|
||||
quit chan struct{}
|
||||
over chan struct{}
|
||||
First *input.Input
|
||||
TrueFirst *input.Input
|
||||
quit chan struct{}
|
||||
over chan struct{}
|
||||
First *input.Input
|
||||
//TrueFirst *input.Input
|
||||
Second *input.Input
|
||||
closefight bool
|
||||
overl sync.Once
|
||||
@@ -99,7 +99,7 @@ func (f *FightC) GetRand() *rand.Rand {
|
||||
// 获取随机数
|
||||
func (f *FightC) IsFirst(play common.PlayerI) bool {
|
||||
|
||||
return f.TrueFirst.Player == play
|
||||
return f.First.Player == play
|
||||
}
|
||||
func (f *FightC) Chat(c common.PlayerI, msg string) {
|
||||
|
||||
|
||||
@@ -266,6 +266,8 @@ func (our *Input) Parseskill(skill *action.SelectSkillAction) {
|
||||
// t.Alive() //先让效果保持存活
|
||||
our.EffectCache = append(our.EffectCache, t)
|
||||
// i.NewEffects = append(i.NewEffects, t)
|
||||
} else {
|
||||
fmt.Println("技能效果不存在", v)
|
||||
}
|
||||
|
||||
temparg = temparg[args:]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
element "blazing/common/data/Element"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"sync"
|
||||
@@ -124,6 +125,17 @@ func (e *EffectNode) PropBefer(in *input.Input, prop int8, level int8, ptype inf
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *EffectNode) ISNaturalEnemy() bool {
|
||||
|
||||
t, _ := element.Calculator.GetOffensiveMultiplier(e.Ctx().Opp.CurrentPet.Type, e.Ctx().Our.CurrentPet.Type)
|
||||
|
||||
if t <= 1 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
// func (e *EffectNode) BoolisFalse(t ...bool) bool {
|
||||
|
||||
// if len(t) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user