Asset count

This commit is contained in:
Frank
2026-08-04 18:21:53 +02:00
parent 7a5f6ad3c6
commit 92bc0389d3
4 changed files with 58 additions and 2 deletions
+25
View File
@@ -1102,6 +1102,31 @@ function COHORT:CountAssets(InStock, MissionTypes, Attributes)
return N
end
--- Count available assets in legion warehouse stock. Spawned, requested and reserved assets are not counted.
-- @param #COHORT self
-- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types.
-- @param #table Attributes (Optional) Count only assest that have a certain attribute(s), e.g. `WAREHOUSE.Attribute.AIR_BOMBER`.
-- @return #number Number of assets.
function COHORT:CountAvailableAssets(MissionTypes, Attributes)
local N=0
for _,_asset in pairs(self.assets) do
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
if not (asset.spawned or asset.requested or asset.isReserved) then
if MissionTypes==nil or AUFTRAG.CheckMissionCapability(MissionTypes, self.missiontypes) then
if Attributes==nil or self:CheckAttribute(Attributes) then
N=N+1 --This is in stock.
end
end
end
end
return N
end
--- Get OPSGROUPs.
-- @param #COHORT self
-- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types.
+16
View File
@@ -2112,6 +2112,22 @@ function COMMANDER:CountAssets(InStock, MissionTypes, Attributes)
return N
end
--- Count available assets of all assigned legions, which are in stock. Spawned and reserved assets are not counted.
-- @param #COMMANDER self
-- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types.
-- @param #table Attributes (Optional) Count only assest that have a certain attribute(s), e.g. `WAREHOUSE.Attribute.AIR_BOMBER`.
-- @return #number Amount of asset groups.
function COMMANDER:CountAvailableAssets(MissionTypes, Attributes)
local N=0
for _,_legion in pairs(self.legions) do
local legion=_legion --Ops.Legion#LEGION
N=N+legion:CountAvailableAssets(MissionTypes, Attributes)
end
return N
end
--- Count assets of all assigned legions.
-- @param #COMMANDER self
-- @param #table MissionTypes (Optional) Count only missions of these types. Default is all types.
@@ -856,8 +856,6 @@ end
function INTEL:SetAgentAuto(switch)
if switch==nil then
switch=true
else
switch=false
end
self.update_detectionset=switch
return self
+17
View File
@@ -2098,6 +2098,23 @@ function LEGION:CountAssets(InStock, MissionTypes, Attributes)
return N
end
--- Count total number of available assets in the legion stock.
-- @param #LEGION self
-- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types.
-- @param #table Attributes (Optional) Count only assest that have a certain attribute(s), e.g. `GROUP.Attribute.AIR_BOMBER`.
-- @return #number Amount of asset groups in stock.
function LEGION:CountAvailableAssets(MissionTypes, Attributes)
local N=0
for _,_cohort in pairs(self.cohorts) do
local cohort=_cohort --Ops.Cohort#COHORT
N=N+cohort:CountAvailableAssets(MissionTypes,Attributes)
end
return N
end
--- Get OPSGROUPs that are spawned and alive.
-- @param #LEGION self
-- @param #table MissionTypes (Optional) Get only assest that can perform certain mission type(s). Default is all types.