15
|
1 // This file (UnitRequirementMaxNumber.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
|
0
|
2 //
|
15
|
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.
|
0
|
4
|
|
5 using System;
|
|
6 using IBBoard.WarFoundry.API.Objects;
|
|
7
|
|
8 namespace IBBoard.WarFoundry.API.Requirements
|
|
9 {
|
|
10 public class UnitRequirementMaxNumber : UnitRequirement
|
|
11 {
|
|
12 private int maxUnitCount;
|
|
13
|
|
14 public UnitRequirementMaxNumber(UnitType type, int maxNumber) : base(type)
|
|
15 {
|
|
16 maxUnitCount = maxNumber;
|
|
17 }
|
|
18
|
|
19 public override string Description
|
|
20 {
|
|
21 get { return "You may only include up to "+maxUnitCount+" "+unitType.Name+" units in an army"; }
|
|
22 }
|
|
23
|
|
24 protected override AbstractFailedRequirement CanAddToArmy (Army army, UnitType type)
|
|
25 {
|
|
26 FailedUnitRequirement failed = null;
|
|
27
|
|
28 if (army.GetUnitTypeCount(type) >= maxUnitCount)
|
|
29 {
|
|
30 failed = new FailedUnitRequirement(this);
|
|
31 }
|
|
32
|
|
33 return failed;
|
|
34 }
|
|
35
|
|
36 protected override AbstractFailedRequirement CanRemoveFromArmy (Army army, UnitType type)
|
|
37 {
|
|
38 return null;
|
|
39 }
|
|
40 }
|
|
41 }
|