0
|
1 using System;
|
|
2 using System.Collections.Generic;
|
|
3 using IBBoard.WarFoundry.API;
|
|
4 using IBBoard.WarFoundry.API.Objects;
|
|
5
|
|
6 namespace IBBoard.WarFoundry.API.Requirements
|
|
7 {
|
|
8 /// <summary>
|
|
9 /// Summary description for UnitRequirement.
|
|
10 /// </summary>
|
|
11 public abstract class UnitRequirement : AbstractArmyRequirement
|
|
12 {
|
|
13 protected UnitType unitType;
|
|
14
|
|
15 protected UnitRequirement(UnitType requirementFor)
|
|
16 {
|
|
17 unitType = requirementFor;
|
|
18 }
|
|
19
|
|
20 /// <summary>
|
|
21 /// Checks whether the specified unit type can be added to the specified army. Returns a <see cref="FailedRequirement"> obejct if a unit of that type cannot legally be added, or no failure (null) if it can be added.
|
|
22 /// </summary>
|
|
23 /// <param name="army">
|
|
24 /// The <see cref="Army"/> that the unit should be checked for adding to
|
|
25 /// </param>
|
|
26 /// <param name="type">
|
|
27 /// The <see cref="UnitType"/> that is being checked.
|
|
28 /// </param>
|
|
29 /// <returns>
|
|
30 /// A <see cref="AbstractFailedRequirement"/> if the requirement means the <see cref="UnitType"/> cannot be legally added, else <code>null</code>.
|
|
31 /// </returns>
|
|
32 protected abstract AbstractFailedRequirement CanAddToArmy(Army army, UnitType type);
|
|
33
|
|
34 /// <summary>
|
|
35 /// Checks whether the specified unit can be added to the specified army. Returns a <see cref="FailedRequirement"> obejct if the unit cannot legally be added, or no failure (null) if it can be added.
|
|
36 /// </summary>
|
|
37 /// <param name="army">
|
|
38 /// The <see cref="Army"/> that the unit should be checked for adding to
|
|
39 /// </param>
|
|
40 /// <param name="type">
|
|
41 /// The <see cref="Unit"/> that is being checked.
|
|
42 /// </param>
|
|
43 /// <returns>
|
|
44 /// A <see cref="AbstractFailedRequirement"/> if the requirement means the <see cref="Unit"/> cannot be legally added, else <code>null</code>.
|
|
45 /// </returns>
|
|
46 protected AbstractFailedRequirement CanAddToArmy(Army army, Unit unit)
|
|
47 {
|
|
48 return CanAddToArmy(army, unit.UnitType);
|
|
49 }
|
|
50
|
|
51 /// <summary>
|
|
52 /// Checks whether the specified unit type can be removed from the specified army. Returns a <see cref="FailedRequirement"> obejct if a unit of that type cannot legally be removed, or no failure (null) if it can be removed.
|
|
53 /// </summary>
|
|
54 /// <param name="army">
|
|
55 /// The <see cref="Army"/> that the unit should be checked for adding to
|
|
56 /// </param>
|
|
57 /// <param name="type">
|
|
58 /// The <see cref="UnitType"/> that is being checked.
|
|
59 /// </param>
|
|
60 /// <returns>
|
|
61 /// A <see cref="AbstractFailedRequirement"/> if the requirement means the <see cref="UnitType"/> cannot be legally added, else <code>null</code>.
|
|
62 /// </returns>
|
|
63 protected abstract AbstractFailedRequirement CanRemoveFromArmy(Army army, UnitType type);
|
|
64
|
|
65 /// <summary>
|
|
66 /// Checks whether the specified unit can be removed from the specified army. Returns a <see cref="FailedRequirement"> obejct if the unit cannot legally be removed, or no failure (null) if it can be removed.
|
|
67 /// </summary>
|
|
68 /// <param name="army">
|
|
69 /// The <see cref="Army"/> that the unit should be checked for adding to
|
|
70 /// </param>
|
|
71 /// <param name="type">
|
|
72 /// The <see cref="Unit"/> that is being checked.
|
|
73 /// </param>
|
|
74 /// <returns>
|
|
75 /// A <see cref="AbstractFailedRequirement"/> if the requirement means the <see cref="Unit"/> cannot be legally removed, else <code>null</code>.
|
|
76 /// </returns>
|
|
77 protected AbstractFailedRequirement CanRemoveFromArmy(Army army, Unit unit)
|
|
78 {
|
|
79 return CanRemoveFromArmy(army, unit.UnitType);
|
|
80 }
|
|
81
|
|
82 protected override AbstractFailedRequirement CanAddToArmy(Army army)
|
|
83 {
|
|
84 return CanAddToArmy(army, unitType);
|
|
85 }
|
|
86
|
|
87 protected override AbstractFailedRequirement CanRemoveFromArmy(Army army)
|
|
88 {
|
|
89 return CanRemoveFromArmy(army, unitType);
|
|
90 }
|
|
91 }
|
|
92 }
|