annotate API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs @ 455:afc6410e4efc

Re #379: Fix validation of requirements to check for unit * Move to "Unit" requirements, since we assume things depend on units * Rename some classes to more meaningful names from unit-based change * Rename "requires N for M" requirement as we can make it more flexible
author IBBoard <dev@ibboard.co.uk>
date Wed, 22 Feb 2012 20:45:39 +0000
parents
children 52baffdd2ab9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
455
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file(RequiresNUnitsForMUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or(at your option) any later version. Please see COPYING for more information and the full license.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System.Collections.Generic;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.Text;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 namespace IBBoard.WarFoundry.API.Objects.Requirement
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 public abstract class RequiresNUnitsForMObjectsRequirement<OBJECT_TYPE> : AbstractUnitRequirement<OBJECT_TYPE> where OBJECT_TYPE : IWarFoundryObject
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public RequiresNUnitsForMObjectsRequirement(OBJECT_TYPE allowedObject, params UnitType[] requiredUnitTypes) : base(allowedObject, requiredUnitTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 //Do nothing
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 public override int GetHashCode()
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 int hash = 0;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 foreach (UnitCountRequirementData req in RequiredTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 hash += req.UnitType.GetHashCode();
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 return hash;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 protected override bool TypeEquals(object obj)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 RequiresNUnitsForMObjectsRequirement<OBJECT_TYPE> otherReq = (RequiresNUnitsForMObjectsRequirement<OBJECT_TYPE>)obj;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 if (!Collections.Collections.AreEqual(RequiredTypes, otherReq.RequiredTypes))
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 return false;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 else
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 return true;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 protected override string GetFailedAddingRequirementsString(IWarFoundryObject toAdd, Army toArmy)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 return String.Join("; ", GetFailedAddingRequirements(toAdd, toArmy).ToArray());
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 private List<string> GetFailedAddingRequirements(IWarFoundryObject obj, Army toArmy)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 List<string> failures = new List<string>();
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 int allowedObjectCount = GetAllowedObjectCount(toArmy, AllowedObject, obj);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 foreach (UnitCountRequirementData limit in RequiredTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 int limitedTypeCount = GetUnitTypesCount(toArmy, limit.UnitTypes, obj);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 if (!IsValidByRequirement(obj, toArmy, limit, allowedObjectCount))
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 string unitTypeList = GetUnitTypeList(limit);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 failures.Add(String.Format("{0} × {1} for every {2} × {3} (would have {4} for {5})", limit.Count, unitTypeList, limit.AllowsCount, AllowedObject.Name, limitedTypeCount, allowedObjectCount));
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 return failures;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 private string GetUnitTypeList(UnitCountRequirementData limit)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 List<String> namesList = new List<String>();
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 foreach (UnitType unitType in limit.UnitTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 namesList.Add(unitType.Name);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 string[] names = namesList.ToArray();
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 return String.Join(" or ", names);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 private bool IsValidByRequirement(IWarFoundryObject wfObject, Army toArmy, UnitCountRequirementData limit, int allowedTypeCount)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 int limitedTypeCount = GetUnitTypesCount(toArmy, limit.UnitTypes, wfObject);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82 return IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 int wholeNumLimited = (limitedTypeCount / limit.Count);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 double allowedRatio = (limit.AllowsCount / (limit.Count * 1.0));
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 return allowedRatio * wholeNumLimited >= allowedTypeCount;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 Validation canAdd = Validation.NotApplicable;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 UnitType addedUnitType = (wfObject is Unit) ? ((Unit)wfObject).UnitType : wfObject as UnitType;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 bool typeFound = (wfObject == (IWarFoundryObject)AllowedObject);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 int allowedTypeCount = GetAllowedObjectCount(toArmy, AllowedObject, wfObject);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 foreach (UnitCountRequirementData limit in RequiredTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 typeFound |= (addedUnitType == limit.UnitType);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 if (!IsValidByRequirement(wfObject, toArmy, limit, allowedTypeCount))
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 canAdd = Validation.Failed;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 break;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 if (typeFound && canAdd == Validation.NotApplicable)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 canAdd = Validation.Passed;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 return canAdd;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 private int GetUnitTypesCount(Army toArmy, UnitType[] unitTypes, IWarFoundryObject wfObject)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 int count = 0;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 foreach (UnitType unitType in unitTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 count += GetUnitTypeCount(toArmy, unitType, wfObject);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 return count;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 private int GetAllowedObjectCount(Army toArmy, OBJECT_TYPE obj, IWarFoundryObject wfObject)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132 return GetObjectCountFromArmy(toArmy, obj) + GetCountFromObject(wfObject, obj);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 protected abstract int GetObjectCountFromArmy(Army toArmy, OBJECT_TYPE obj);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 private int GetCountFromObject(IWarFoundryObject wfObject, OBJECT_TYPE limitedType)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 return (limitedType.Equals(wfObject) || (wfObject is Unit && ((Unit)wfObject).UnitType.Equals(limitedType))) ? 1 : 0;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 public override Validation ValidatesArmy(Army army)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144 Validation canAdd = Validation.NotApplicable;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 int allowedTypeCount = GetObjectCountFromArmy(army, AllowedObject);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146 bool typeFound = (allowedTypeCount > 0);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
147
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 foreach (UnitCountRequirementData limit in RequiredTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
149 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150 int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
151 typeFound |= (limitedTypeCount > 0);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
152
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 if (!IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount))
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
154 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
155 canAdd = Validation.Failed;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
156 break;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160 if (typeFound && canAdd == Validation.NotApplicable)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 canAdd = Validation.Passed;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 return canAdd;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168 protected override string GetFailedRequirementsString(Army army)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170 return String.Join("; ", GetFailedValidationRequirements(army).ToArray());
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173 private List<string> GetFailedValidationRequirements(Army army)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 List<string> failures = new List<string>();
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 int allowedTypeCount = GetAllowedObjectCount(army);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 foreach (UnitCountRequirementData limit in RequiredTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180 int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182 if (!IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount))
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
184 string unitTypeList = GetUnitTypeList(limit);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 failures.Add(String.Format("{0} × {1} for every {2} × {3} (have {4} for {5})", limit.Count, unitTypeList, limit.AllowsCount, AllowedObject.Name, limitedTypeCount, allowedTypeCount));
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189 return failures;
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
191
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 protected abstract int GetAllowedObjectCount(Army army);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
193
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
194 private int GetUnitTypesCount(Army army, UnitType[] unitTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
195 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
196 return GetUnitTypesCount(army, unitTypes, null);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
197 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
198
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
199 /// <summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
200 /// Adds a requirement for there to be at least minCount of a given UnitType, allowing allowedCount of this UnitType
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
201 /// </summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 /// <param name='unitType'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203 /// The unit type to require.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
205 /// <param name='minCount'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
206 /// The minimum number of that type that must exist.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
207 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
208 /// <param name='allowedCount'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
209 /// The number of units allowed for every minCount units of the supplied unit type.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
210 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
211 public void AddUnitTypeRequirement(UnitType unitType, int minCount, int allowedCount)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
213 RequiredTypes.Add(new UnitCountRequirementData(unitType, minCount, allowedCount));
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
215
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216 /// <summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
217 /// Adds a requirement for there to be at least one of a given UnitType, allowing allowedCount of this UnitType
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 /// </summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
219 /// <param name='unitType'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220 /// The unit type to require.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222 /// <param name='allowedCount'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
223 /// The number of units allowed for each unit of the supplied unit type.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
224 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
225 public void AddUnitTypeRequirement(UnitType unitType, int allowedCount)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
227 AddUnitTypeRequirement(allowedCount, unitType);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
228 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
229
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
230 public override void AddUnitTypeRequirement(UnitType unitType)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
231 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
232 AddUnitTypeRequirement(1, unitType);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
233 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
234
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
235 /// <summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
236 /// Adds a requirement for there to be one or more of the given UnitTypes, allowing one of this UnitType. If multiple unit types
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
237 /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType).
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
238 /// </summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
239 /// <param name='unitType'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
240 /// The unit type or types to require.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
241 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
242 public void AddUnitTypeRequirement(params UnitType[] unitTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
243 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
244 AddUnitTypeRequirement(1, unitTypes);
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
245 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
246
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
247 /// <summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
248 /// Adds a requirement for there to be one or more of the given UnitTypes, allowing allowsAmount of this UnitType. If multiple unit types
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
249 /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType).
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
250 /// </summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
251 /// <param name="allowsAmount">
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
252 /// The number of units to be allowed for each 1 of unitType
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
253 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
254 /// <param name='unitType'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
255 /// The unit type or types to require.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
256 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
257 public void AddUnitTypeRequirement(int allowsAmount, params UnitType[] unitTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
258 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
259 RequiredTypes.Add(new UnitCountRequirementData(unitTypes, 1, allowsAmount));
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
260 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
261
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
262 /// <summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
263 /// Adds a requirement for there to be minCount or more of the given UnitTypes, allowing allowsAmount of this UnitType. If multiple unit types
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
264 /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType).
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
265 /// </summary>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
266 /// <param name='minCount'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
267 /// The minimum number of that type that must exist.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
268 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
269 /// <param name="allowsAmount">
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
270 /// The number of units to be allowed for each 1 of unitType
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
271 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
272 /// <param name='unitType'>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
273 /// The unit type or types to require.
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
274 /// </param>
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
275 public void AddUnitTypeRequirement(int minCount, int allowsAmount, params UnitType[] unitTypes)
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
276 {
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
277 RequiredTypes.Add(new UnitCountRequirementData(unitTypes, minCount, allowsAmount));
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
278 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
279 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
280 }
afc6410e4efc Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
281