Mercurial > repos > IBBoard.WarFoundry.API
changeset 208:e8e9026dd4ea
Fixes #216: Export unit abilities in to HTML
* Add export of ability names in HTML
* Restructure the equipment export code so that there is some degree of differentiation between equipments and abilities
Re #213: Add abilities to units
* Add initial stub "Abilities" property to unit that returns required abilities
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 09 Nov 2009 16:49:27 +0000 |
parents | 897c53d5a8aa |
children | 1cde49671c8b |
files | api/Exporters/WarFoundryHtmlExporter.cs api/Objects/Unit.cs |
diffstat | 2 files changed, 50 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Exporters/WarFoundryHtmlExporter.cs Mon Nov 09 12:30:05 2009 +0000 +++ b/api/Exporters/WarFoundryHtmlExporter.cs Mon Nov 09 16:49:27 2009 +0000 @@ -143,20 +143,50 @@ } StringBuilder sb = new StringBuilder(); - bool addSeparator = false; - - foreach (UnitEquipmentItem equip in unit.GetEquipment()) + UnitEquipmentItem[] unitEquipment = unit.GetEquipment (); + + if (unitEquipment.Length > 0) { - if (!addSeparator) + bool addSeparator = false; + + foreach (UnitEquipmentItem equip in unitEquipment) { - addSeparator = true; + if (!addSeparator) + { + addSeparator = true; + } + else + { + sb.Append(", "); + } + + sb.Append(Translation.GetTranslation("armyHtmlExportEquipAmountRatio", "{0} for {1}", equip.Name, unit.GetEquipmentAmountString(equip))); } - else + + sb.Append(". "); + } + + ICollection<Ability> abilities = unit.Abilities; + + if (abilities.Count > 0) + { + bool addSeparator = false; + + foreach (Ability ability in abilities) { - sb.Append(", "); + if (!addSeparator) + { + addSeparator = true; + } + else + { + sb.Append(", "); + } + + sb.Append(ability.Name); } - - sb.Append(Translation.GetTranslation("armyHtmlExportEquipAmountRatio", "{0} for {1}", equip.Name, unit.GetEquipmentAmountString(equip))); + + sb.Append(". "); } XmlElement notes = doc.CreateElement("td");
--- a/api/Objects/Unit.cs Mon Nov 09 12:30:05 2009 +0000 +++ b/api/Objects/Unit.cs Mon Nov 09 16:49:27 2009 +0000 @@ -562,6 +562,17 @@ return amount; } + + /// <summary> + /// Default stub implementation of getting the unit's abilities - defaults to just the unit type's required abilities until we get a way to modify them + /// </summary> + public ICollection<Ability> Abilities + { + get + { + return UnitType.GetRequiredAbilities(); + } + } } }