Mercurial > repos > IBBoard.WarFoundry.API
annotate api/Requirements/UnitRequirementMinNumber.cs @ 176:22429737cd77
Re #198: Add slots with counts to units
* Migrate to using new Limit objects from ibboard:ticket:24
* Parse new objects
* Move more data type definitions in to Core schema for re-use
* Make UnitType just return limit objects
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 22 Oct 2009 19:51:42 +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 (UnitRequirementMinNumber.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 UnitRequirementMinNumber : UnitRequirement | |
11 { | |
12 private int minUnitCount; | |
13 | |
14 public UnitRequirementMinNumber(UnitType type, int minNumber) : base(type) | |
15 { | |
16 minUnitCount = minNumber; | |
17 } | |
18 | |
19 public override string Description | |
20 { | |
21 get { return "You must include at least "+minUnitCount+" "+unitType.Name+" units in an army"; } | |
22 } | |
23 | |
24 protected override AbstractFailedRequirement CanAddToArmy(Army army, UnitType type) | |
25 { | |
26 return null; | |
27 } | |
28 | |
29 protected override AbstractFailedRequirement CanRemoveFromArmy (Army army, UnitType type) | |
30 { | |
31 FailedUnitRequirement failed = null; | |
32 | |
33 if (army.GetUnitTypeCount(type) <= minUnitCount) | |
34 { | |
35 failed = new FailedUnitRequirement(this); | |
36 } | |
37 | |
38 return failed; | |
39 } | |
40 } | |
41 } |