comparison API/Exporters/WarFoundryXMLWithXSLExporter.cs @ 401: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 9a49d34599fb
children 5d7584a73d7f
comparison
equal deleted inserted replaced
400:0cfa43fd9020 401:3a71f8af5bde
95 armyUnit.SetAttribute("models", uni.Size.ToString()); 95 armyUnit.SetAttribute("models", uni.Size.ToString());
96 96
97 foreach (UnitEquipmentItem equip in uni.GetEquipment()) 97 foreach (UnitEquipmentItem equip in uni.GetEquipment())
98 { 98 {
99 XmlElement armyEquipmentItem = armyList.CreateElement("equipmentItem"); 99 XmlElement armyEquipmentItem = armyList.CreateElement("equipmentItem");
100 armyEquipmentItem.SetAttribute("count", equip.CostMultiplier.ToString()); 100 //armyEquipmentItem.SetAttribute("count", equip.CostMultiplier.ToString());
101 101
102 // Item Name 102 // Item Name
103 XmlElement armyEquipmentName = armyList.CreateElement("name"); 103 XmlElement armyEquipmentName = armyList.CreateElement("name");
104 armyEquipmentName.InnerText = equip.Name; 104 armyEquipmentName.InnerText = equip.Name;
105 armyEquipmentItem.AppendChild(armyEquipmentName); 105 armyEquipmentItem.AppendChild(armyEquipmentName);
106 106
107 // Item description 107 int armyEquipAmount = 0;
108 XmlElement armyEquipmentDesc = armyList.CreateElement("desc");
109 double amount = UnitEquipmentUtil.GetEquipmentAmount(uni, equip);
110 string amountString = "";
111 108
112 109 if (UnitEquipmentUtil.GetEquipmentAmount(uni, equip) == null)
113 // TODO Change to report number, no string needed, add as attribute to armyEquipmentItem
114 if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(uni, equip))
115 { 110 {
116 if (amount == 100) 111 armyEquipAmount = 0;
117 {
118 amountString = GetEquipmentAmountAllTranslation(uni);
119 }
120 else
121 {
122 int number = UnitEquipmentUtil.GetEquipmentAmountTaken(uni, equip);
123 amountString = GetEquipmentAmountRatioTranslation(amount, number);
124 }
125 } 112 }
126 else 113 else
127 { 114 {
128 if (amount == -1) 115 armyEquipAmount = (int)UnitEquipmentUtil.GetEquipmentAmount(uni, equip);
129 {
130 amountString = GetEquipmentAmountAllTranslation(uni);
131 }
132 else
133 {
134 amountString = GetEquipmentAmountNumberTranslation((int)amount);
135 }
136 } 116 }
137 armyEquipmentDesc.InnerText = Translation.GetTranslation("armyHtmlExportEquipAmountRatio","{0} for {1}", equip.Name, amountString); 117
138 armyEquipmentItem.SetAttribute("count", amountString); 118 if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(uni, equip))
119 {
120 float fraction = (float)(armyEquipAmount / 100.0);
121 armyEquipAmount = (int)(fraction * uni.Size);
122 }
123
124 armyEquipmentItem.SetAttribute("count", armyEquipAmount.ToString());
139 125
140 armyEquipmentItem.AppendChild(armyEquipmentDesc);
141 armyUnit.AppendChild(armyEquipmentItem); 126 armyUnit.AppendChild(armyEquipmentItem);
142 } 127 }
143 128
144 foreach (Ability abil in uni.Abilities) 129 foreach (Ability abil in uni.Abilities)
145 { 130 {