From 8329fc5213d18884ca298b0a2ca7f62202ee8153 Mon Sep 17 00:00:00 2001 From: Alain Gilbert Date: Tue, 26 Jan 2021 13:02:04 -0800 Subject: [PATCH] add HasFlyableShips to ShipsInfos --- ships.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ships.go b/ships.go index 61ae3d1d..9ad4117a 100644 --- a/ships.go +++ b/ships.go @@ -52,6 +52,19 @@ func (s ShipsInfos) HasShips() bool { return false } +// HasFlyableShips returns either or not at least one flyable ship is present +func (s ShipsInfos) HasFlyableShips() bool { + for _, ship := range Ships { + shipID := ship.GetID() + if shipID.IsFlyableShip() { + if s.ByID(shipID) > 0 { + return true + } + } + } + return false +} + // Speed returns the speed of the slowest ship func (s ShipsInfos) Speed(techs Researches, isCollector, isGeneral bool) int64 { var minSpeed int64 = math.MaxInt64