56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package input
|
|
|
|
// TeamSlots 返回当前输入所在阵营的全部有效战斗位视图。
|
|
func (our *Input) TeamSlots() []*Input {
|
|
if our == nil {
|
|
return nil
|
|
}
|
|
if len(our.Team) == 0 {
|
|
return []*Input{our}
|
|
}
|
|
slots := make([]*Input, 0, len(our.Team))
|
|
for _, teammate := range our.Team {
|
|
if teammate == nil {
|
|
continue
|
|
}
|
|
slots = append(slots, teammate)
|
|
}
|
|
return slots
|
|
}
|
|
|
|
// Teammates 返回队友列表,不包含自己。
|
|
func (our *Input) Teammates() []*Input {
|
|
if our == nil {
|
|
return nil
|
|
}
|
|
teammates := make([]*Input, 0, len(our.Team))
|
|
for _, teammate := range our.TeamSlots() {
|
|
if teammate == nil || teammate == our {
|
|
continue
|
|
}
|
|
teammates = append(teammates, teammate)
|
|
}
|
|
return teammates
|
|
}
|
|
|
|
// LivingTeammates 返回当前仍有存活出战精灵的队友列表。
|
|
func (our *Input) LivingTeammates() []*Input {
|
|
if our == nil {
|
|
return nil
|
|
}
|
|
teammates := make([]*Input, 0, len(our.Team))
|
|
for _, teammate := range our.Teammates() {
|
|
currentPet := teammate.CurrentPet()
|
|
if currentPet == nil || currentPet.Info.Hp == 0 {
|
|
continue
|
|
}
|
|
teammates = append(teammates, teammate)
|
|
}
|
|
return teammates
|
|
}
|
|
|
|
// HasLivingTeammate 用于快速判断当前战斗位是否还有存活队友。
|
|
func (our *Input) HasLivingTeammate() bool {
|
|
return len(our.LivingTeammates()) > 0
|
|
}
|