0
|
1 // UnitRequirementMinNumber.cs
|
|
2 //
|
|
3 // Copyright (C) 2008 IBBoard
|
|
4 //
|
|
5 // This library is free software; you can redistribute it and/or
|
|
6 // modify it under the terms of the GNU Lesser General Public
|
|
7 // License version 2.1 of the License as published by the Free
|
|
8 // Software Foundation.
|
|
9 //
|
|
10 // This library is distributed in the hope that it will be useful,
|
|
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 // Lesser General Public License for more details.
|
|
14 //
|
|
15 // You should have received a copy of the GNU Lesser General Public
|
|
16 // License along with this library; if not, write to the Free Software
|
|
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 //
|
|
19 //
|
|
20
|
|
21 using System;
|
|
22 using IBBoard.WarFoundry.API.Objects;
|
|
23
|
|
24 namespace IBBoard.WarFoundry.API.Requirements
|
|
25 {
|
|
26 public class UnitRequirementMinNumber : UnitRequirement
|
|
27 {
|
|
28 private int minUnitCount;
|
|
29
|
|
30 public UnitRequirementMinNumber(UnitType type, int minNumber) : base(type)
|
|
31 {
|
|
32 minUnitCount = minNumber;
|
|
33 }
|
|
34
|
|
35 public override string Description
|
|
36 {
|
|
37 get { return "You must include at least "+minUnitCount+" "+unitType.Name+" units in an army"; }
|
|
38 }
|
|
39
|
|
40 protected override AbstractFailedRequirement CanAddToArmy(Army army, UnitType type)
|
|
41 {
|
|
42 return null;
|
|
43 }
|
|
44
|
|
45 protected override AbstractFailedRequirement CanRemoveFromArmy (Army army, UnitType type)
|
|
46 {
|
|
47 FailedUnitRequirement failed = null;
|
|
48
|
|
49 if (army.GetUnitTypeCount(type) <= minUnitCount)
|
|
50 {
|
|
51 failed = new FailedUnitRequirement(this);
|
|
52 }
|
|
53
|
|
54 return failed;
|
|
55 }
|
|
56 }
|
|
57 }
|