fix: 修复战斗动作提交逻辑

This commit is contained in:
xinian
2026-04-03 00:02:34 +08:00
committed by cnb
parent 43881fd988
commit c19ee7de03
4 changed files with 52 additions and 211 deletions

View File

@@ -6,6 +6,10 @@ import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/modules/player/model"
<<<<<<< ours
=======
"context"
>>>>>>> theirs
"github.com/jinzhu/copier"
)
@@ -44,6 +48,17 @@ func (f *FightC) submitAction(act action.BattleActionI) {
return
}
<<<<<<< ours
=======
round := f.actionRound.Load()
if round == 0 {
cool.Logger.Printf(context.Background(), logMsg, userID, targetID)
return
}
act.SetRound(round)
>>>>>>> theirs
f.actionMu.Lock()
if !f.acceptActions {
f.actionMu.Unlock()
@@ -75,6 +90,7 @@ func (f *FightC) submitAction(act action.BattleActionI) {
default:
}
}
<<<<<<< ours
func (f *FightC) nextAction() action.BattleActionI {
f.actionMu.Lock()
@@ -82,6 +98,8 @@ func (f *FightC) nextAction() action.BattleActionI {
f.actionMu.Unlock()
return nil
}
=======
>>>>>>> theirs
act := f.pendingActions[0]
copy(f.pendingActions, f.pendingActions[1:])
@@ -200,12 +218,21 @@ func (f *FightC) UseItem(c common.PlayerI, cacthid, itemid uint32) {
return
}
<<<<<<< ours
=======
>>>>>>> theirs
if f.Info.Mode == info.BattleMode.PET_MELEE {
go f.UseSkill(c, 0)
return
}
<<<<<<< ours
f.submitAction(&action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: itemid, CacthTime: cacthid})
=======
f.submitAction(&action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: itemid, CacthTime: cacthid},
"action round is not ready, failed to send UseItem, userID: %d, skillID: %d",
c.GetInfo().UserID, cacthid)
>>>>>>> theirs
}
// ReadyFight 处理玩家战斗准备逻辑,当满足条件时启动战斗循环

View File

@@ -319,6 +319,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
FAttack: *f.First.AttackValue,
SAttack: *f.Second.AttackValue,
}
f.actionRound.Store(uint32(f.Round + 1))
//因为切完才能广播,所以必须和回合结束分开结算
f.Broadcast(func(fighter *input.Input) {
for _, switchAction := range f.Switch {

View File

@@ -36,6 +36,7 @@ type FightC struct {
acceptActions bool
pendingActions []action.BattleActionI // 待处理动作队列,同一玩家最多保留两段动作
<<<<<<< ours
quit chan struct{}
over chan struct{}
First *input.Input
@@ -44,6 +45,17 @@ type FightC struct {
closefight bool
overl sync.Once
waittime int
=======
quit chan struct{}
over chan struct{}
First *input.Input
TrueFirst *input.Input
Second *input.Input
closefight bool
overl sync.Once
waittime int
actionRound atomic.Uint32
>>>>>>> theirs
model.FightOverInfo
//战斗结束的插装
callback func(model.FightOverInfo)