Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Objects/UnitType.cs @ 348:d34ae0057a39
Re #27: Unit requirements
* Obsolete methods using the old requirements system
* Switch to new IRequirement objects
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 09 Apr 2011 16:01:02 +0000 |
parents | 3c4a6403a88c |
children | 51cccccf3669 |
comparison
equal
deleted
inserted
replaced
347:44a6539fadf9 | 348:d34ae0057a39 |
---|---|
6 using System.Collections.Generic; | 6 using System.Collections.Generic; |
7 using System.Xml; | 7 using System.Xml; |
8 using IBBoard.Limits; | 8 using IBBoard.Limits; |
9 using IBBoard.Logging; | 9 using IBBoard.Logging; |
10 using IBBoard.WarFoundry.API.Requirements; | 10 using IBBoard.WarFoundry.API.Requirements; |
11 using IBBoard.WarFoundry.API.Objects.Requirement; | |
11 | 12 |
12 namespace IBBoard.WarFoundry.API.Objects | 13 namespace IBBoard.WarFoundry.API.Objects |
13 { | 14 { |
14 /// <summary> | 15 /// <summary> |
15 /// A UnitType is a type for a <see cref=" Unit"/>, normally relating to an entry in an army list. The UnitType defines the name, cost, minimum and maximum limits of a unit, and the equipment units of the type can take. | 16 /// A UnitType is a type for a <see cref=" Unit"/>, normally relating to an entry in an army list. The UnitType defines the name, cost, minimum and maximum limits of a unit, and the equipment units of the type can take. |
21 private int min, max, baseSize = 0; | 22 private int min, max, baseSize = 0; |
22 private int minSize, maxSize; | 23 private int minSize, maxSize; |
23 private double baseUnitCost; | 24 private double baseUnitCost; |
24 private double costPerTrooper; | 25 private double costPerTrooper; |
25 private Stats stats; | 26 private Stats stats; |
26 private List<UnitRequirement> requirements = new List<UnitRequirement>(); | 27 private List<IRequirement> requirements = new List<IRequirement>(); |
27 private Dictionary<string, UnitEquipmentItem> equipment = new Dictionary<string, UnitEquipmentItem>(); | 28 private Dictionary<string, UnitEquipmentItem> equipment = new Dictionary<string, UnitEquipmentItem>(); |
28 private Dictionary<string, List<UnitEquipmentItem>> equipmentExclusionGroups = new Dictionary<string, List<UnitEquipmentItem>>(); | 29 private Dictionary<string, List<UnitEquipmentItem>> equipmentExclusionGroups = new Dictionary<string, List<UnitEquipmentItem>>(); |
29 private List<string> equipmentKeyOrder = new List<string>(); | 30 private List<string> equipmentKeyOrder = new List<string>(); |
30 private Dictionary<string, Ability> requiredAbilities = new Dictionary<string, Ability>(); | 31 private Dictionary<string, Ability> requiredAbilities = new Dictionary<string, Ability>(); |
31 private Dictionary<string, Ability> optionalAbilities = new Dictionary<string, Ability>(); | 32 private Dictionary<string, Ability> optionalAbilities = new Dictionary<string, Ability>(); |
455 optionalAbilities[id] = ability; | 456 optionalAbilities[id] = ability; |
456 } | 457 } |
457 } | 458 } |
458 } | 459 } |
459 | 460 |
460 public void AddRequirement(UnitRequirement requirement) | 461 public void AddRequirement(IRequirement requirement) |
461 { | 462 { |
462 requirements.Add(requirement); | 463 requirements.Add(requirement); |
463 } | 464 } |
464 | 465 |
465 public UnitRequirement[] Requirements | 466 public IRequirement[] GetRequirements() |
466 { | 467 { |
467 get { return requirements.ToArray(); } | 468 return requirements.ToArray(); |
468 } | 469 } |
469 | 470 |
471 [Obsolete] | |
470 public List<FailedUnitRequirement> CanAddToArmy(Army army) | 472 public List<FailedUnitRequirement> CanAddToArmy(Army army) |
471 { | 473 { |
472 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>(); | 474 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>(); |
473 | |
474 if (requirements!=null && requirements.Count > 0) | |
475 { | |
476 foreach (UnitRequirement requirement in requirements) | |
477 { | |
478 FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanAddToWarFoundryObject(army); | |
479 | |
480 if (failure!=null) | |
481 { | |
482 failures.Add(failure); | |
483 } | |
484 } | |
485 } | |
486 | |
487 return failures; | 475 return failures; |
488 } | 476 } |
489 | 477 |
478 [Obsolete] | |
490 public List<FailedUnitRequirement> CanRemoveFromArmy(Army army) | 479 public List<FailedUnitRequirement> CanRemoveFromArmy(Army army) |
491 { | 480 { |
492 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>(); | 481 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>(); |
493 | |
494 if (requirements!=null && requirements.Count > 0) | |
495 { | |
496 foreach (UnitRequirement requirement in requirements) | |
497 { | |
498 FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanRemoveFromWarFoundryObject(army); | |
499 | |
500 if (failure!=null) | |
501 { | |
502 failures.Add(failure); | |
503 } | |
504 } | |
505 } | |
506 | |
507 return failures; | 482 return failures; |
508 } | 483 } |
509 | 484 |
510 public string Notes | 485 public string Notes |
511 { | 486 { |