refactor(fight/effect): 重构回合开始逻辑,移除PlayerI.GetAction接口并将行动逻辑移至Input.GetAction方法,新增EffectStatus处理战斗状态效果
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
)
|
||||
|
||||
type PlayerI interface {
|
||||
GetAction()
|
||||
GetPlayerCaptureContext() *info.PlayerCaptureContext
|
||||
Roll(int, int) (bool, float64, float64)
|
||||
SendPack(b []byte) error
|
||||
|
||||
@@ -1 +1,28 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
|
||||
// 施加一个基类effect
|
||||
type EffectStatus struct {
|
||||
node.EffectNode
|
||||
status info.EnumBattleStatus
|
||||
}
|
||||
|
||||
func init() {
|
||||
//麻痹,疲惫,害怕,石化,都是无法行动
|
||||
|
||||
tt := func(t info.EnumBattleStatus, f *EffectStatus) {
|
||||
|
||||
f.status=t
|
||||
input.InitStatusEffect(int(t), f)
|
||||
}
|
||||
tt(info.BattleStatus.Paralysis, &EffectStatus{})
|
||||
tt(info.BattleStatus.Tired, &EffectStatus{})
|
||||
tt(info.BattleStatus.Sleep, &EffectStatus{})
|
||||
tt(info.BattleStatus.Petrified, &EffectStatus{})
|
||||
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ func (f *FightC) battleLoop() {
|
||||
|
||||
if action.GetPlayerID() != 0 && f.Info.FightId == 3 {
|
||||
|
||||
f.GetInputByAction(action, true).Player.GetAction()
|
||||
f.GetInputByAction(action, true).GetAction(f.Our)
|
||||
|
||||
}
|
||||
|
||||
@@ -465,7 +465,6 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) {
|
||||
attacker, defender = f.First, f.Second
|
||||
attackeraction = fattack
|
||||
attacker.First = true //先手技能
|
||||
//attacker.BattleActionI, defender.BattleActionI = fattack, sattack
|
||||
|
||||
} else {
|
||||
attacker, defender = f.Second, f.First
|
||||
@@ -479,10 +478,7 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) {
|
||||
continue
|
||||
|
||||
}
|
||||
|
||||
//**回合开始前enterturn
|
||||
|
||||
attacker.Exec(func(t input.Effect) bool { //计算命中
|
||||
attacker.Exec(func(t input.Effect) bool { //回合开始前
|
||||
|
||||
//结算状态
|
||||
t.OnTurnStart(defender)
|
||||
@@ -541,7 +537,6 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) {
|
||||
SAttack: *f.Second.AttackValue,
|
||||
}
|
||||
|
||||
|
||||
for i := 0; i < 20; i++ { //堆叠状态剩余回合
|
||||
ate, ok := attacker.GetStatusEffect(i)
|
||||
if ok {
|
||||
|
||||
@@ -17,3 +17,8 @@ func (u *Input) SetProp(prop, level int) {
|
||||
//todo 待交互
|
||||
|
||||
}
|
||||
func (u *Input) GetAction(opp *Input) {
|
||||
//使用1#技能,实际上要按照四个技能权重去使用
|
||||
u.FightC.UseSkill(u.Player, int32(u.FightC.GetCurrPET(u.Player).Skills[0].ID))
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
type Effect interface {
|
||||
OnBattleStart() bool //战斗开始
|
||||
|
||||
OnTurnStart(opp *Input) bool //回合开始
|
||||
OnTurnStart(opp *Input) //回合开始
|
||||
|
||||
UseSkill(opp *Input) bool //使用技能 可以取消用技能节点
|
||||
SkillUseEnd(opp *Input)
|
||||
|
||||
@@ -11,11 +11,10 @@ func (e *EffectNode) PreTurnStart() bool {
|
||||
}
|
||||
|
||||
// 回合开始
|
||||
func (e *EffectNode) OnTurnStart(opp *input.Input) bool {
|
||||
func (e *EffectNode) OnTurnStart(opp *input.Input) {
|
||||
|
||||
//处理异常状态
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 回合结束一次性effect清楚掉
|
||||
|
||||
@@ -34,10 +34,6 @@ func (f *AI_player) SendFightEndInfo(_ info.FightOverInfo) {
|
||||
//fmt.Println("战斗结束")
|
||||
|
||||
}
|
||||
func (f *AI_player) GetAction() {
|
||||
//使用1#技能,实际上要按照四个技能权重去使用
|
||||
f.FightC.UseSkill(f, int32(f.FightC.GetCurrPET(f).Skills[0].ID))
|
||||
}
|
||||
|
||||
func (p *AI_player) GetPetInfo() []model.PetInfo {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user