Mercurial > repos > snowblizz-super-API-ideas
changeset 237:ec7fe85116cf
Fixes #254: Basic HTML export outputs "-1" for equipment amounts instead of "all"
* Output "all" and number for "-1" numeric amount
* Clean up export code
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 21 Feb 2010 20:13:44 +0000 |
parents | ca2905c9b225 |
children | d1068f4b6d1c |
files | api/Exporters/WarFoundryHtmlExporter.cs |
diffstat | 1 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Exporters/WarFoundryHtmlExporter.cs Sat Feb 20 20:57:13 2010 +0000 +++ b/api/Exporters/WarFoundryHtmlExporter.cs Sun Feb 21 20:13:44 2010 +0000 @@ -166,20 +166,27 @@ if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, equip)) { - int number = UnitEquipmentUtil.GetEquipmentAmountTaken(unit, equip); if (amount == 100) { - amountString = Translation.GetTranslation("armyHtmlExportEquipAmountAll", "all ({1})", amount, number); + amountString = GetEquipmentAmountAllTranslation(unit); } else { - amountString = Translation.GetTranslation("armyHtmlExportEquipAmountPercentage", "{0}% ({1})", amount, number); + int number = UnitEquipmentUtil.GetEquipmentAmountTaken(unit, equip); + amountString = GetEquipmentAmountRatioTranslation (amount, number); } } else { - amountString = Translation.GetTranslation("armyHtmlExportEquipAmountNumber", "{0}", amount); + if (amount == -1) + { + amountString = GetEquipmentAmountAllTranslation(unit); + } + else + { + amountString = GetEquipmentAmountNumberTranslation((int)amount); + } } sb.Append(Translation.GetTranslation("armyHtmlExportEquipAmountRatio", "{0} for {1}", equip.Name, amountString)); @@ -221,5 +228,20 @@ return row; } + + private string GetEquipmentAmountRatioTranslation (double amount, int number) + { + return Translation.GetTranslation ("armyHtmlExportEquipAmountPercentage", "{0}% ({1})", amount, number); + } + + private string GetEquipmentAmountNumberTranslation(int amount) + { + return Translation.GetTranslation("armyHtmlExportEquipAmountNumber", "{0}", amount); + } + + private string GetEquipmentAmountAllTranslation(Unit unit) + { + return Translation.GetTranslation("armyHtmlExportEquipAmountAll", "all ({1})", 100, unit.Size); + } } }