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 diff
     1.1 --- a/API/Exporters/WarFoundryXMLWithXSLExporter.cs	Sun Aug 14 14:40:16 2011 -0600
     1.2 +++ b/API/Exporters/WarFoundryXMLWithXSLExporter.cs	Mon Aug 15 07:53:58 2011 -0600
     1.3 @@ -97,47 +97,32 @@
     1.4                      foreach (UnitEquipmentItem equip in uni.GetEquipment())
     1.5                      {
     1.6                          XmlElement armyEquipmentItem = armyList.CreateElement("equipmentItem");
     1.7 -                        armyEquipmentItem.SetAttribute("count", equip.CostMultiplier.ToString());
     1.8 +                        //armyEquipmentItem.SetAttribute("count", equip.CostMultiplier.ToString());
     1.9                          
    1.10                          // Item Name
    1.11                          XmlElement armyEquipmentName = armyList.CreateElement("name");
    1.12                          armyEquipmentName.InnerText = equip.Name;
    1.13                          armyEquipmentItem.AppendChild(armyEquipmentName);
    1.14  
    1.15 -                        // Item description
    1.16 -                        XmlElement armyEquipmentDesc = armyList.CreateElement("desc");
    1.17 -                        double amount = UnitEquipmentUtil.GetEquipmentAmount(uni, equip);
    1.18 -                        string amountString = "";
    1.19 +                        int armyEquipAmount = 0;
    1.20  
    1.21 -                        
    1.22 -                        // TODO Change to report number, no string needed, add as attribute to armyEquipmentItem
    1.23 -                        if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(uni, equip))
    1.24 +                        if (UnitEquipmentUtil.GetEquipmentAmount(uni, equip) == null)
    1.25                          {
    1.26 -                            if (amount == 100)
    1.27 -                            {
    1.28 -                                amountString = GetEquipmentAmountAllTranslation(uni);
    1.29 -                            }
    1.30 -                            else
    1.31 -                            {
    1.32 -                                int number = UnitEquipmentUtil.GetEquipmentAmountTaken(uni, equip);
    1.33 -                                amountString = GetEquipmentAmountRatioTranslation(amount, number);
    1.34 -                            }
    1.35 +                            armyEquipAmount = 0;
    1.36                          }
    1.37                          else
    1.38                          {
    1.39 -                            if (amount == -1)
    1.40 -                            {
    1.41 -                                amountString = GetEquipmentAmountAllTranslation(uni);
    1.42 -                            }
    1.43 -                            else
    1.44 -                            {
    1.45 -                                amountString = GetEquipmentAmountNumberTranslation((int)amount);
    1.46 -                            }
    1.47 +                            armyEquipAmount = (int)UnitEquipmentUtil.GetEquipmentAmount(uni, equip);
    1.48                          }
    1.49 -                        armyEquipmentDesc.InnerText = Translation.GetTranslation("armyHtmlExportEquipAmountRatio","{0} for {1}", equip.Name, amountString);
    1.50 -                        armyEquipmentItem.SetAttribute("count", amountString);
    1.51 +                        
    1.52 +                        if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(uni, equip))
    1.53 +                        {
    1.54 +                            float fraction = (float)(armyEquipAmount / 100.0);
    1.55 +                            armyEquipAmount = (int)(fraction * uni.Size);
    1.56 +                        }
    1.57 +
    1.58 +                        armyEquipmentItem.SetAttribute("count", armyEquipAmount.ToString());
    1.59                         
    1.60 -                        armyEquipmentItem.AppendChild(armyEquipmentDesc);
    1.61                          armyUnit.AppendChild(armyEquipmentItem);
    1.62                      }
    1.63