Mercurial > repos > IBBoard.WarFoundry.API
diff API/Objects/ArmyCategory.cs @ 471:0a2068897793
Re #359: Add "only contained" attribute to unit types
* Add "main units" methods to get only top-level units
* Add nesting to unit creation command
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 15 Apr 2012 20:52:32 +0100 |
parents | 1a70ca80ef41 |
children | aac77204ae0e |
line wrap: on
line diff
--- a/API/Objects/ArmyCategory.cs Sat Apr 14 20:44:22 2012 +0100 +++ b/API/Objects/ArmyCategory.cs Sun Apr 15 20:52:32 2012 +0100 @@ -98,6 +98,21 @@ return units.ToArray(); } + public Unit[] GetMainUnits() + { + List<Unit> mainUnits = new List<Unit>(); + + foreach (Unit unit in units) + { + if (unit.ParentUnit == null) + { + mainUnits.Add(unit); + } + } + + return mainUnits.ToArray(); + } + private double TotalPoints { get { return pointsTotal; }