chore: update fight logic and effect implementations
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
This commit is contained in:
@@ -22,14 +22,14 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, skill *info
|
||||
skill.AttackTimeC(attacker.Prop[5]) //计算命中
|
||||
|
||||
defender.ExecWithOpponent(attacker, func(effect input.Effect) bool { //计算闪避,然后修改对方命中),同时相当于计算属性无效这种
|
||||
effect.Ctx().SkillEntity = skill
|
||||
f.setEffectSkillContext(effect, skill, defender)
|
||||
effect.SkillHit_ex()
|
||||
return true
|
||||
})
|
||||
|
||||
attacker.ExecWithOpponent(defender, func(effect input.Effect) bool {
|
||||
//计算变威力
|
||||
effect.Ctx().SkillEntity = skill
|
||||
f.setEffectSkillContext(effect, skill, defender)
|
||||
effect.SkillHit() //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率
|
||||
return true
|
||||
})
|
||||
@@ -45,7 +45,7 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, skill *info
|
||||
originalPetInfo[0], originalPetInfo[1] = attackerPet.Info, defenderPet.Info
|
||||
attacker.ExecWithOpponent(defender, func(effect input.Effect) bool {
|
||||
//计算变威力
|
||||
effect.Ctx().SkillEntity = skill
|
||||
f.setEffectSkillContext(effect, skill, defender)
|
||||
effect.CalculatePre() //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率
|
||||
return true
|
||||
})
|
||||
@@ -94,7 +94,7 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, skill *info
|
||||
|
||||
// 扣减防御方血量
|
||||
attacker.ExecWithOpponent(defender, func(effect input.Effect) bool {
|
||||
effect.Ctx().SkillEntity = skill
|
||||
f.setEffectSkillContext(effect, skill, defender)
|
||||
effect.OnSkill() //调用伤害计算
|
||||
return true
|
||||
})
|
||||
@@ -135,6 +135,47 @@ func (f *FightC) getSkillParticipants(skillAction *action.SelectSkillAction) (*i
|
||||
return f.GetInputByAction(skillAction, false), f.GetInputByAction(skillAction, true)
|
||||
}
|
||||
|
||||
// setEffectSkillContext 统一设置技能阶段 effect 上下文。
|
||||
// 规则:
|
||||
// 1) Our/Opp 由 ExecWithOpponent 负责写入(carrier / 对位)。
|
||||
// 2) Target 统一表示“本次动作被选中的目标位”,在攻防双方 hook 中保持一致。
|
||||
func (f *FightC) setEffectSkillContext(effect input.Effect, skill *info.SkillEntity, target *input.Input) {
|
||||
if effect == nil {
|
||||
return
|
||||
}
|
||||
ctx := effect.Ctx()
|
||||
ctx.SkillEntity = skill
|
||||
if target != nil {
|
||||
ctx.Target = target
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FightC) setEffectTarget(effect input.Effect, target *input.Input) {
|
||||
if effect == nil || target == nil {
|
||||
return
|
||||
}
|
||||
effect.Ctx().Target = target
|
||||
}
|
||||
|
||||
// plannedOpponentForCarrier 为旧 effect 提供“当前动作对应目标”上下文:
|
||||
// 1) 若 carrier 是本回合出手方,返回其动作目标。
|
||||
// 2) 若无匹配动作,返回 nil,交给 Input 默认 OppTeam 回退。
|
||||
func (f *FightC) plannedOpponentForCarrier(carrier *input.Input, acts ...*action.SelectSkillAction) *input.Input {
|
||||
if carrier == nil {
|
||||
return nil
|
||||
}
|
||||
for _, act := range acts {
|
||||
if act == nil {
|
||||
continue
|
||||
}
|
||||
attacker, defender := f.getSkillParticipants(act)
|
||||
if attacker == carrier {
|
||||
return defender
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *FightC) collectAttackValues(inputs []*input.Input) []model.AttackValue {
|
||||
values := make([]model.AttackValue, 0, len(inputs))
|
||||
for actorIndex, fighter := range inputs {
|
||||
@@ -172,7 +213,9 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
|
||||
ff.EffectCache = make([]input.Effect, 0) //先把上一回合数据清空,但是应该把本身延续类效果集成过来
|
||||
ff.EffectLost = make([]input.Effect, 0)
|
||||
ff.Exec(func(effect input.Effect) bool { //回合开始前
|
||||
opponent := f.plannedOpponentForCarrier(ff, firstAttack, secondAttack)
|
||||
ff.ExecWithOpponent(opponent, func(effect input.Effect) bool { //回合开始前
|
||||
f.setEffectTarget(effect, opponent)
|
||||
effect.TurnStart(firstAttack, secondAttack)
|
||||
return true
|
||||
})
|
||||
@@ -187,7 +230,9 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
attackerInput.Parseskill(skillAction)
|
||||
}
|
||||
f.Broadcast(func(fighter *input.Input) {
|
||||
fighter.Exec(func(effect input.Effect) bool { //回合开始前
|
||||
opponent := f.plannedOpponentForCarrier(fighter, firstAttack, secondAttack)
|
||||
fighter.ExecWithOpponent(opponent, func(effect input.Effect) bool { //回合开始前
|
||||
f.setEffectTarget(effect, opponent)
|
||||
effect.ComparePre(firstAttack, secondAttack) //先结算技能的优先级
|
||||
return true
|
||||
})
|
||||
@@ -262,11 +307,11 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
|
||||
currentSkill = originalSkill
|
||||
defender.ExecWithOpponent(attacker, func(effect input.Effect) bool { //这个是能否使用技能
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
f.setEffectSkillContext(effect, currentSkill, defender)
|
||||
return effect.ActionStartEx(firstAttack, secondAttack)
|
||||
})
|
||||
canUseSkill := attacker.ExecWithOpponent(defender, func(effect input.Effect) bool { //这个是能否使用技能
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
f.setEffectSkillContext(effect, currentSkill, defender)
|
||||
return effect.ActionStart(firstAttack, secondAttack)
|
||||
})
|
||||
|
||||
@@ -302,7 +347,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
if ok {
|
||||
usecount := 1
|
||||
attacker.ExecWithOpponent(defender, func(effect input.Effect) bool { //技能使用后的我方效果
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
f.setEffectSkillContext(effect, currentSkill, defender)
|
||||
effect.HookPP(&usecount)
|
||||
return true
|
||||
})
|
||||
@@ -312,7 +357,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
if defenderPet != nil && defenderPet.Info.Hp > 0 {
|
||||
//技能使用后
|
||||
defender.ExecWithOpponent(attacker, func(effect input.Effect) bool { //技能使用后的我方效果
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
f.setEffectSkillContext(effect, currentSkill, defender)
|
||||
effect.Skill_Use_ex()
|
||||
return true
|
||||
})
|
||||
@@ -321,20 +366,20 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
if attackerPet != nil && attackerPet.Info.Hp > 0 {
|
||||
//技能使用后
|
||||
attacker.ExecWithOpponent(defender, func(effect input.Effect) bool { //技能使用后的我方效果
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
f.setEffectSkillContext(effect, currentSkill, defender)
|
||||
effect.Skill_Use()
|
||||
return true
|
||||
})
|
||||
}
|
||||
//技能使用后
|
||||
defender.ExecWithOpponent(attacker, func(effect input.Effect) bool { //技能使用后的我方效果
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
f.setEffectSkillContext(effect, currentSkill, defender)
|
||||
effect.Action_end_ex()
|
||||
return true
|
||||
})
|
||||
//技能使用后
|
||||
attacker.ExecWithOpponent(defender, func(effect input.Effect) bool { //技能使用后的我方效果
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
f.setEffectSkillContext(effect, currentSkill, defender)
|
||||
effect.Action_end()
|
||||
return true
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user