46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package fight
|
|
|
|
import (
|
|
"blazing/logic/service/fight/action"
|
|
"testing"
|
|
)
|
|
|
|
func TestSubmitActionKeepsDifferentActorSlots(t *testing.T) {
|
|
f := &FightC{
|
|
acceptActions: true,
|
|
pendingActions: make([]action.BattleActionI, 0, 4),
|
|
}
|
|
f.actionRound.Store(1)
|
|
|
|
first := &action.SelectSkillAction{BaseAction: action.BaseAction{PlayerID: 1001, ActorIndex: 0}}
|
|
second := &action.SelectSkillAction{BaseAction: action.BaseAction{PlayerID: 1001, ActorIndex: 1}}
|
|
|
|
f.submitAction(first)
|
|
f.submitAction(second)
|
|
|
|
if got := len(f.pendingActions); got != 2 {
|
|
t.Fatalf("expected 2 pending actions, got %d", got)
|
|
}
|
|
}
|
|
|
|
func TestSubmitActionReplacesSameActorSlot(t *testing.T) {
|
|
f := &FightC{
|
|
acceptActions: true,
|
|
pendingActions: make([]action.BattleActionI, 0, 4),
|
|
}
|
|
f.actionRound.Store(1)
|
|
|
|
first := &action.SelectSkillAction{BaseAction: action.BaseAction{PlayerID: 1001, ActorIndex: 0}}
|
|
replacement := &action.SelectSkillAction{BaseAction: action.BaseAction{PlayerID: 1001, ActorIndex: 0, TargetIndex: 1}}
|
|
|
|
f.submitAction(first)
|
|
f.submitAction(replacement)
|
|
|
|
if got := len(f.pendingActions); got != 1 {
|
|
t.Fatalf("expected 1 pending action, got %d", got)
|
|
}
|
|
if f.pendingActions[0] != replacement {
|
|
t.Fatalf("expected replacement action to be kept")
|
|
}
|
|
}
|