`` refactor(fight): 重构状态效果处理逻辑,统一使用Skill_Hit_Pre方法并修复回合开始触发时机``

待实现寄生种子
This commit is contained in:
1
2025-10-15 14:24:46 +00:00
parent fccdda3c9d
commit cb1abe69b3
2 changed files with 29 additions and 23 deletions

View File

@@ -18,7 +18,8 @@ type StatusNotSkill struct {
EffectStatus EffectStatus
} }
func (e *StatusNotSkill) CanSkill(opp *input.Input) bool { // 不能出手
func (e *StatusNotSkill) Skill_Hit_Pre(input.Ctx) bool {
return false return false
} }
@@ -28,19 +29,16 @@ type DrainHP struct {
EffectStatus EffectStatus
} }
func (e *DrainHP) OnTurnStart(opp *input.Input) { func (e *DrainHP) Skill_Hit_Pre(input input.Ctx) bool {
input.DamageZone = &info.DamageZone{
e.Input.Damage(input.Ctx{ Type: info.DamageType.True, //状态类扣除无法被减伤
Damage: decimal.NewFromUint64(uint64(e.Input.CurrentPet.Info.MaxHp)).
Input: opp,
DamageZone: &info.DamageZone{
Type: info.DamageType.Red,
Damage: decimal.NewFromUint64(uint64(opp.CurrentPet.Info.MaxHp)).
Div(decimal.NewFromInt(8)), Div(decimal.NewFromInt(8)),
}, }
}) e.Input.Damage(input)
return true
} }
// 被寄生种子 扣血类 // 被寄生种子 扣血类
@@ -48,10 +46,13 @@ type StatusDrainedHP struct {
DrainHP DrainHP
} }
func (e *StatusDrainedHP) OnTurnStart(opp *input.Input) { func (e *StatusDrainedHP) Skill_Hit_Pre(input input.Ctx) bool {
e.DrainHP.OnTurnStart(opp) e.DrainHP.Skill_Hit_Pre(input) //先调用父类扣血
//TODO 寄生种子 给对面回血待实现回血buff
opp.CurrentPet.Info.Hp = -e.Input.CurrentPet.Info.MaxHp / 8 // input.CurrentPet.Info.Hp = -e.Input.CurrentPet.Info.MaxHp / 8
return true
} }
func init() { func init() {

View File

@@ -390,7 +390,7 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *action.S
attacker.Exec(func(t input.Effect) bool { //计算命中 miss改命中 attacker.Exec(func(t input.Effect) bool { //计算命中 miss改命中
t.Skill_Hit_Pre(input.Ctx{ //调基础命中 t.Skill_Hit_Pre(input.Ctx{ //调基础命中
Input: attacker, Input: defender,
SkillEntity: a.Skill, SkillEntity: a.Skill,
}) //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率 }) //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率
@@ -552,6 +552,18 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
} }
var attacker, defender *input.Input var attacker, defender *input.Input
f.First.Exec(func(t input.Effect) bool { //回合开始前
//结算状态
t.Turn_Start(input.Ctx{Input: f.First})
return true
})
f.Second.Exec(func(t input.Effect) bool { //回合开始前
//结算状态
t.Turn_Start(input.Ctx{Input: f.Second})
return true
})
//开始回合操作 //开始回合操作
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
var oldskill interface{} var oldskill interface{}
@@ -564,13 +576,6 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
oldskill, _ = deepcopy.Anything(sattack.Skill) //备份技能 oldskill, _ = deepcopy.Anything(sattack.Skill) //备份技能
} }
attacker.Exec(func(t input.Effect) bool { //回合开始前
//结算状态
t.Turn_Start(input.Ctx{Input: attacker})
return true
})
canuseskill := true canuseskill := true
// 实际上攻击方 还有系统选择放弃出手的 // 实际上攻击方 还有系统选择放弃出手的
if IsNil(oldskill) || attacker.CurrentPet.Info.Hp <= 0 { if IsNil(oldskill) || attacker.CurrentPet.Info.Hp <= 0 {