refactor: 重构战斗系统为统一动作包结构
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
55
logic/service/fight/input/team.go
Normal file
55
logic/service/fight/input/team.go
Normal file
@@ -0,0 +1,55 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user