- Added Cohort and Legion classes
- Added Platoon and Brigade classes
This commit is contained in:
Frank
2021-08-10 00:40:17 +02:00
parent 629c5e7739
commit 86bb256bf1
13 changed files with 3041 additions and 82 deletions

View File

@@ -704,7 +704,7 @@ function SQUADRON:onafterStatus(From, Event, To)
local skill=self.skill and tostring(self.skill) or "N/A"
local NassetsTot=#self.assets
local NassetsInS=self:CountAssetsInStock()
local NassetsInS=self:CountAssets(true)
local NassetsQP=0 ; local NassetsP=0 ; local NassetsQ=0
if self.airwing then
NassetsQP, NassetsP, NassetsQ=self.airwing:CountAssetsOnMission(nil, self)
@@ -888,18 +888,25 @@ end
--- Count assets in airwing (warehous) stock.
-- @param #SQUADRON self
-- @param #boolean InStock If true, only assets that are in the warehouse stock/inventory are counted.
-- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types.
-- @return #number Assets not spawned.
function SQUADRON:CountAssetsInStock(MissionTypes)
-- @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 SQUADRON:CountAssets(InStock, MissionTypes, Attributes)
local N=0
for _,_asset in pairs(self.assets) do
local asset=_asset --Ops.AirWing#AIRWING.SquadronAsset
if asset.spawned then
else
if MissionTypes==nil or self:CheckMissionCapability(MissionTypes, self.missiontypes) then
N=N+1
if MissionTypes==nil or self:CheckMissionCapability(MissionTypes, self.missiontypes) then
if Attributes==nil or self:CheckAttribute(Attributes) then
if asset.spawned then
if not InStock then
N=N+1 --Spawned but we also count the spawned ones.
end
else
N=N+1 --This is in stock.
end
end
end
end
@@ -1099,6 +1106,26 @@ function SQUADRON:CheckMissionCapability(MissionTypes, Capabilities)
return false
end
--- Check if the squadron attribute matches the given attribute(s).
-- @param #SQUADRON self
-- @param #table Attributes The requested attributes. See `WAREHOUSE.Attribute` enum. Can also be passed as a single attribute `#string`.
-- @return #boolean If true, the squad has the requested attribute.
function SQUADRON:CheckAttribute(Attributes)
if type(Attributes)~="table" then
Attributes={Attributes}
end
for _,attribute in pairs(Attributes) do
if attribute==self.attribute then
return true
end
end
return false
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------