15
|
1 // This file (UnitExcludesRequirement.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.Objects;
|
|
8
|
|
9 namespace IBBoard.WarFoundry.API.Requirements
|
|
10 {
|
|
11 /// <summary>
|
|
12 /// Summary description for UnitExcludesRequirement.
|
|
13 /// </summary>
|
|
14 public class UnitExcludesRequirement : UnitRequirement
|
|
15 {
|
|
16 private UnitRequirementItem[] excludingTypes;
|
|
17
|
|
18 public UnitExcludesRequirement(UnitType type, UnitRequirementItem[] excludingUnitTypes) : base(type)
|
|
19 {
|
|
20 excludingTypes = excludingUnitTypes;
|
|
21 }
|
|
22
|
|
23 public override string Description
|
|
24 {
|
|
25 get
|
|
26 {
|
|
27 return "Some units are already included that excluded this unit";
|
|
28 }
|
|
29 }
|
|
30
|
|
31 protected override AbstractFailedRequirement CanAddToArmy(Army army, UnitType type)
|
|
32 {
|
|
33 FailedUnitRequirement failed = null;
|
|
34
|
|
35 for (int i = 0; i<excludingTypes.Length; i++)
|
|
36 {
|
|
37 if (army.GetUnitTypeCount(excludingTypes[i].UnitType) > 0)
|
|
38 {
|
|
39 failed = new FailedUnitRequirement(this);
|
|
40 break;
|
|
41 }
|
|
42 }
|
|
43
|
|
44 return failed;
|
|
45 }
|
|
46
|
|
47 protected override AbstractFailedRequirement CanRemoveFromArmy(Army army, UnitType type)
|
|
48 {
|
|
49 return null;
|
|
50 }
|
|
51
|
|
52 }
|
|
53 }
|