15
|
1 // This file (UnitRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
|
|
4
|
0
|
5 using System;
|
|
6 using System.Collections.Generic;
|
|
7 using IBBoard.WarFoundry.API;
|
|
8 using IBBoard.WarFoundry.API.Objects;
|
|
9
|
|
10 namespace IBBoard.WarFoundry.API.Requirements
|
|
11 {
|
|
12 /// <summary>
|
|
13 /// Summary description for UnitRequirement.
|
|
14 /// </summary>
|
|
15 public abstract class UnitRequirement : AbstractArmyRequirement
|
|
16 {
|
|
17 protected UnitType unitType;
|
|
18
|
|
19 protected UnitRequirement(UnitType requirementFor)
|
|
20 {
|
|
21 unitType = requirementFor;
|
|
22 }
|
|
23
|
|
24 /// <summary>
|
|
25 /// 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.
|
|
26 /// </summary>
|
|
27 /// <param name="army">
|
|
28 /// The <see cref="Army"/> that the unit should be checked for adding to
|
|
29 /// </param>
|
|
30 /// <param name="type">
|
|
31 /// The <see cref="UnitType"/> that is being checked.
|
|
32 /// </param>
|
|
33 /// <returns>
|
|
34 /// A <see cref="AbstractFailedRequirement"/> if the requirement means the <see cref="UnitType"/> cannot be legally added, else <code>null</code>.
|
|
35 /// </returns>
|
|
36 protected abstract AbstractFailedRequirement CanAddToArmy(Army army, UnitType type);
|
|
37
|
|
38 /// <summary>
|
|
39 /// 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.
|
|
40 /// </summary>
|
|
41 /// <param name="army">
|
|
42 /// The <see cref="Army"/> that the unit should be checked for adding to
|
|
43 /// </param>
|
|
44 /// <param name="type">
|
|
45 /// The <see cref="Unit"/> that is being checked.
|
|
46 /// </param>
|
|
47 /// <returns>
|
|
48 /// A <see cref="AbstractFailedRequirement"/> if the requirement means the <see cref="Unit"/> cannot be legally added, else <code>null</code>.
|
|
49 /// </returns>
|
|
50 protected AbstractFailedRequirement CanAddToArmy(Army army, Unit unit)
|
|
51 {
|
|
52 return CanAddToArmy(army, unit.UnitType);
|
|
53 }
|
|
54
|
|
55 /// <summary>
|
|
56 /// 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.
|
|
57 /// </summary>
|
|
58 /// <param name="army">
|
|
59 /// The <see cref="Army"/> that the unit should be checked for adding to
|
|
60 /// </param>
|
|
61 /// <param name="type">
|
|
62 /// The <see cref="UnitType"/> that is being checked.
|
|
63 /// </param>
|
|
64 /// <returns>
|
|
65 /// A <see cref="AbstractFailedRequirement"/> if the requirement means the <see cref="UnitType"/> cannot be legally added, else <code>null</code>.
|
|
66 /// </returns>
|
|
67 protected abstract AbstractFailedRequirement CanRemoveFromArmy(Army army, UnitType type);
|
|
68
|
|
69 /// <summary>
|
|
70 /// 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.
|
|
71 /// </summary>
|
|
72 /// <param name="army">
|
|
73 /// The <see cref="Army"/> that the unit should be checked for adding to
|
|
74 /// </param>
|
|
75 /// <param name="type">
|
|
76 /// The <see cref="Unit"/> that is being checked.
|
|
77 /// </param>
|
|
78 /// <returns>
|
|
79 /// A <see cref="AbstractFailedRequirement"/> if the requirement means the <see cref="Unit"/> cannot be legally removed, else <code>null</code>.
|
|
80 /// </returns>
|
|
81 protected AbstractFailedRequirement CanRemoveFromArmy(Army army, Unit unit)
|
|
82 {
|
|
83 return CanRemoveFromArmy(army, unit.UnitType);
|
|
84 }
|
|
85
|
|
86 protected override AbstractFailedRequirement CanAddToArmy(Army army)
|
|
87 {
|
|
88 return CanAddToArmy(army, unitType);
|
|
89 }
|
|
90
|
|
91 protected override AbstractFailedRequirement CanRemoveFromArmy(Army army)
|
|
92 {
|
|
93 return CanRemoveFromArmy(army, unitType);
|
|
94 }
|
|
95 }
|
|
96 }
|