Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Requirements/UnitRequirementMaxNumber.cs @ 159:7b98e71b8511
Re #152: Test and fix extensibility of current schemas
* Add "any" elements and "anyAttributes" to schemas where appropriate
Still need to handle cleansing with XSLT
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 30 Sep 2009 19:08:08 +0000 |
parents | 2f3cafb69799 |
children | 6083010a005c |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
1 // This file (UnitRequirementMaxNumber.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2008, 2009 IBBoard. |
0 | 2 // |
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
15
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. |
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 } |