62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
package fight
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"blazing/logic/service/fight/action"
|
|
fightinfo "blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/modules/player/model"
|
|
)
|
|
|
|
func TestSendLegacyRoundBroadcastSkipsUnexecutedAction(t *testing.T) {
|
|
ourPlayer := &stubPlayer{info: model.PlayerInfo{UserID: 1001}}
|
|
oppPlayer := &stubPlayer{info: model.PlayerInfo{UserID: 2002}}
|
|
|
|
our := input.NewInput(nil, ourPlayer)
|
|
our.InitAttackValue()
|
|
our.AttackValue.SkillID = 111
|
|
our.SetCurPetAt(0, fightinfo.CreateBattlePetEntity(model.PetInfo{
|
|
ID: 11,
|
|
Hp: 80,
|
|
MaxHp: 100,
|
|
CatchTime: 101,
|
|
}))
|
|
|
|
opp := input.NewInput(nil, oppPlayer)
|
|
opp.InitAttackValue()
|
|
opp.SetCurPetAt(0, fightinfo.CreateBattlePetEntity(model.PetInfo{
|
|
ID: 22,
|
|
Hp: 0,
|
|
MaxHp: 100,
|
|
CatchTime: 202,
|
|
}))
|
|
|
|
fc := &FightC{
|
|
Our: []*input.Input{our},
|
|
Opp: []*input.Input{opp},
|
|
LegacyGroupProtocol: true,
|
|
}
|
|
|
|
firstAttack := &action.SelectSkillAction{
|
|
BaseAction: action.BaseAction{PlayerID: ourPlayer.info.UserID, ActorIndex: 0, TargetIndex: 0},
|
|
}
|
|
secondAttack := &action.SelectSkillAction{
|
|
BaseAction: action.BaseAction{PlayerID: oppPlayer.info.UserID, ActorIndex: 0, TargetIndex: 0},
|
|
}
|
|
|
|
fc.sendLegacyRoundBroadcast(firstAttack, secondAttack)
|
|
|
|
for _, player := range []*stubPlayer{ourPlayer, oppPlayer} {
|
|
if len(player.sentCmds) != 2 {
|
|
t.Fatalf("expected one skill packet plus bout done, got %v", player.sentCmds)
|
|
}
|
|
if player.sentCmds[0] != groupCmdSkillHurt {
|
|
t.Fatalf("expected first packet to be skill hurt, got %d", player.sentCmds[0])
|
|
}
|
|
if player.sentCmds[1] != groupCmdBoutDone {
|
|
t.Fatalf("expected second packet to be bout done, got %d", player.sentCmds[1])
|
|
}
|
|
}
|
|
}
|