Mercurial > repos > IBBoard.WarFoundry.API
comparison api/Requirements/UnitRequirementMaxNumber.cs @ 0:520818033bb6
Initial commit of WarFoundry code
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 19 Dec 2008 15:57:51 +0000 |
parents | |
children | 306558904c2a |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:520818033bb6 |
---|---|
1 // UnitRequirementMaxNumber.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 UnitRequirementMaxNumber : UnitRequirement | |
27 { | |
28 private int maxUnitCount; | |
29 | |
30 public UnitRequirementMaxNumber(UnitType type, int maxNumber) : base(type) | |
31 { | |
32 maxUnitCount = maxNumber; | |
33 } | |
34 | |
35 public override string Description | |
36 { | |
37 get { return "You may only include up to "+maxUnitCount+" "+unitType.Name+" units in an army"; } | |
38 } | |
39 | |
40 protected override AbstractFailedRequirement CanAddToArmy (Army army, UnitType type) | |
41 { | |
42 FailedUnitRequirement failed = null; | |
43 | |
44 if (army.GetUnitTypeCount(type) >= maxUnitCount) | |
45 { | |
46 failed = new FailedUnitRequirement(this); | |
47 } | |
48 | |
49 return failed; | |
50 } | |
51 | |
52 protected override AbstractFailedRequirement CanRemoveFromArmy (Army army, UnitType type) | |
53 { | |
54 return null; | |
55 } | |
56 } | |
57 } |