changeset 402:3a71f8af5bde xml-basic

Correct count of unit items
author Dan.Kulinski@dank-laptop.Global.Local
date Mon, 15 Aug 2011 07:53:58 -0600
parents 0cfa43fd9020
children cf8fc32e020a
files API/Exporters/WarFoundryXMLWithXSLExporter.cs
diffstat 1 files changed, 13 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/API/Exporters/WarFoundryXMLWithXSLExporter.cs	Sun Aug 14 14:40:16 2011 -0600
+++ b/API/Exporters/WarFoundryXMLWithXSLExporter.cs	Mon Aug 15 07:53:58 2011 -0600
@@ -97,47 +97,32 @@
                     foreach (UnitEquipmentItem equip in uni.GetEquipment())
                     {
                         XmlElement armyEquipmentItem = armyList.CreateElement("equipmentItem");
-                        armyEquipmentItem.SetAttribute("count", equip.CostMultiplier.ToString());
+                        //armyEquipmentItem.SetAttribute("count", equip.CostMultiplier.ToString());
                         
                         // Item Name
                         XmlElement armyEquipmentName = armyList.CreateElement("name");
                         armyEquipmentName.InnerText = equip.Name;
                         armyEquipmentItem.AppendChild(armyEquipmentName);
 
-                        // Item description
-                        XmlElement armyEquipmentDesc = armyList.CreateElement("desc");
-                        double amount = UnitEquipmentUtil.GetEquipmentAmount(uni, equip);
-                        string amountString = "";
+                        int armyEquipAmount = 0;
 
-                        
-                        // TODO Change to report number, no string needed, add as attribute to armyEquipmentItem
-                        if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(uni, equip))
+                        if (UnitEquipmentUtil.GetEquipmentAmount(uni, equip) == null)
                         {
-                            if (amount == 100)
-                            {
-                                amountString = GetEquipmentAmountAllTranslation(uni);
-                            }
-                            else
-                            {
-                                int number = UnitEquipmentUtil.GetEquipmentAmountTaken(uni, equip);
-                                amountString = GetEquipmentAmountRatioTranslation(amount, number);
-                            }
+                            armyEquipAmount = 0;
                         }
                         else
                         {
-                            if (amount == -1)
-                            {
-                                amountString = GetEquipmentAmountAllTranslation(uni);
-                            }
-                            else
-                            {
-                                amountString = GetEquipmentAmountNumberTranslation((int)amount);
-                            }
+                            armyEquipAmount = (int)UnitEquipmentUtil.GetEquipmentAmount(uni, equip);
                         }
-                        armyEquipmentDesc.InnerText = Translation.GetTranslation("armyHtmlExportEquipAmountRatio","{0} for {1}", equip.Name, amountString);
-                        armyEquipmentItem.SetAttribute("count", amountString);
+                        
+                        if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(uni, equip))
+                        {
+                            float fraction = (float)(armyEquipAmount / 100.0);
+                            armyEquipAmount = (int)(fraction * uni.Size);
+                        }
+
+                        armyEquipmentItem.SetAttribute("count", armyEquipAmount.ToString());
                        
-                        armyEquipmentItem.AppendChild(armyEquipmentDesc);
                         armyUnit.AppendChild(armyEquipmentItem);
                     }