feat(fight): 优化精灵切换逻辑并添加切换动作队列
This commit is contained in:
@@ -18,9 +18,11 @@ import (
|
||||
type FightC struct {
|
||||
Info info.NoteReadyToFightInfo
|
||||
|
||||
ownerID uint32 // 战斗发起者ID
|
||||
Our *input.Input //始终等于房主ID
|
||||
Opp *input.Input //对手ID
|
||||
ownerID uint32 // 战斗发起者ID
|
||||
Our *input.Input //始终等于房主ID
|
||||
Opp *input.Input //对手ID
|
||||
Switch []*ActiveSwitchAction
|
||||
|
||||
rand *rand.Rand
|
||||
StartTime time.Time
|
||||
actionChan chan BattleActionI // 所有操作统一从这里进入
|
||||
@@ -237,10 +239,12 @@ func (f *FightC) battleLoop() {
|
||||
}
|
||||
|
||||
if a, isExpelled := action.(*ActiveSwitchAction); isExpelled {
|
||||
//fmt.Println("对方死亡切换")
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
|
||||
ff.Player.SendChangePet(a.Reason)
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
if ff.Player.ID() == a.PlayerID { //先给自身广播
|
||||
ff.Player.SendChangePet(a.Reason)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if f.GetInputByAction(action, false).CanChange {
|
||||
@@ -557,8 +561,15 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) {
|
||||
}
|
||||
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
for _, v := range f.Switch {
|
||||
if ff.Player.ID() != v.PlayerID{
|
||||
ff.Player.SendChangePet(v.Reason)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ff.Player.SendAttackValue(ret)
|
||||
})
|
||||
f.Switch = []*ActiveSwitchAction{}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
|
||||
ret := &ActiveSwitchAction{
|
||||
BaseAction: NewBaseAction(c.GetInfo().UserID),
|
||||
}
|
||||
f.Switch = append(f.Switch, ret)
|
||||
|
||||
f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user