Files
bl/logic/service/fight/input/team_test.go
xinian f433a26a6d
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor: 重构战斗系统为统一动作包结构
2026-04-06 00:58:23 +08:00

31 lines
876 B
Go

package input
import (
"testing"
fightinfo "blazing/logic/service/fight/info"
"blazing/modules/player/model"
)
func TestLivingTeammatesFiltersSelfAndDeadSlots(t *testing.T) {
owner := &Input{CurPet: []*fightinfo.BattlePetEntity{{Info: model.PetInfo{Hp: 10}}}}
aliveMate := &Input{CurPet: []*fightinfo.BattlePetEntity{{Info: model.PetInfo{Hp: 5}}}}
deadMate := &Input{CurPet: []*fightinfo.BattlePetEntity{{Info: model.PetInfo{Hp: 0}}}}
team := []*Input{owner, aliveMate, deadMate}
owner.Team = team
aliveMate.Team = team
deadMate.Team = team
teammates := owner.LivingTeammates()
if len(teammates) != 1 {
t.Fatalf("expected 1 living teammate, got %d", len(teammates))
}
if teammates[0] != aliveMate {
t.Fatalf("expected alive teammate to be returned")
}
if owner.HasLivingTeammate() != true {
t.Fatalf("expected owner to detect living teammate")
}
}