comparison api/Objects/Unit.cs @ 38:548cfc776f54

Fixes #34 - Remove "Choices" and "Base/Increment" from Category * Remove Choices and Base/Increment from code Re #47: Remove magic numbers * Replace "-1" magic number with WarFoundryCore.INFINITY * Use INFINITY instead of -1 in code * Use INF in schemas instead of -1 * Handle and parse INF as a special value in XML Factory
author IBBoard <dev@ibboard.co.uk>
date Thu, 19 Mar 2009 20:11:07 +0000
parents 306558904c2a
children 3a90f70dac73
comparison
equal deleted inserted replaced
37:465a215a21a2 38:548cfc776f54
97 points+= Math.Floor(size * count) * equipItem.Cost; 97 points+= Math.Floor(size * count) * equipItem.Cost;
98 } 98 }
99 } 99 }
100 else 100 else
101 { 101 {
102 if (count == -1) 102 if (count == WarFoundryCore.INFINITY)
103 { 103 {
104 points+= size * equipItem.Cost; 104 points+= size * equipItem.Cost;
105 } 105 }
106 else 106 else
107 { 107 {
286 } 286 }
287 //else what was passed in was okay 287 //else what was passed in was okay
288 } 288 }
289 else 289 else
290 { 290 {
291 if (amount >=1 || amount == -1) 291 if (amount >=1 || amount == WarFoundryCore.INFINITY)
292 { 292 {
293 amount = (float)Math.Round(amount); 293 amount = (float)Math.Round(amount);
294 } 294 }
295 else 295 else
296 { 296 {
305 oldAmount = (float)equipment[equipID]; 305 oldAmount = (float)equipment[equipID];
306 } 306 }
307 307
308 if (amount!=oldAmount) 308 if (amount!=oldAmount)
309 { 309 {
310 if (amount > 0 || amount == -1) 310 if (amount > 0 || amount == WarFoundryCore.INFINITY)
311 { 311 {
312 equipment[equipID] = amount; 312 equipment[equipID] = amount;
313 } 313 }
314 else 314 else
315 { 315 {
367 367
368 public Stats UnitStats 368 public Stats UnitStats
369 { 369 {
370 get { return UnitType.UnitStats; } 370 get { return UnitType.UnitStats; }
371 } 371 }
372
373 /*public override string ToXmlString()
374 {
375 StringBuilder sb = new StringBuilder();
376 float amount;
377
378 foreach(string key in equipment.Keys)
379 {
380 amount = (float)equipment[key];
381
382 if (amount > 0 || amount == -1)
383 {
384 sb.Append("<equipItem id=\""+key+"\" amount=\""+amount+"\" />");
385 }
386 }
387
388 string equipmentString;
389
390 if (sb.Length > 0)
391 {
392 equipmentString = "<equipment>"+sb.ToString()+"</equipment>";
393 }
394 else
395 {
396 equipmentString = "";
397 }
398
399 if (equipmentString == "")
400 {
401 return "<unit id=\""+ID+"\" unitType=\""+UnitType.ID+"\" unitName=\""+name+"\" size=\""+Size+"\" />";
402 }
403 else
404 {
405 return "<unit id=\""+ID+"\" unitType=\""+UnitType.ID+"\" unitName=\""+name+"\" size=\""+Size+"\">"+equipmentString+"</unit>";
406 }
407 }*/
408 } 372 }
409 } 373 }