Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Requirements/UnitRequirementMinNumber.cs @ 231:d1c90159547a
Fixes #236: Race loading should fail cleanly if system doesn't exist
* Exception if we get a null game system
Also:
* Remove unused variable
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 24 Dec 2009 14:54:43 +0000 |
parents | 6083010a005c |
children |
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; | |
229
6083010a005c
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
6 using IBBoard.Lang; |
0 | 7 using IBBoard.WarFoundry.API.Objects; |
8 | |
9 namespace IBBoard.WarFoundry.API.Requirements | |
10 { | |
11 public class UnitRequirementMinNumber : UnitRequirement | |
12 { | |
13 private int minUnitCount; | |
14 | |
15 public UnitRequirementMinNumber(UnitType type, int minNumber) : base(type) | |
16 { | |
17 minUnitCount = minNumber; | |
18 } | |
19 | |
20 public override string Description | |
21 { | |
229
6083010a005c
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
22 get { return Translation.GetTranslation("requirementUnitMinNumber", "you must include at least {0} of {1} in an army", minUnitCount, unitType.Name); } |
0 | 23 } |
24 | |
25 protected override AbstractFailedRequirement CanAddToArmy(Army army, UnitType type) | |
26 { | |
27 return null; | |
28 } | |
29 | |
30 protected override AbstractFailedRequirement CanRemoveFromArmy (Army army, UnitType type) | |
31 { | |
32 FailedUnitRequirement failed = null; | |
33 | |
34 if (army.GetUnitTypeCount(type) <= minUnitCount) | |
35 { | |
36 failed = new FailedUnitRequirement(this); | |
37 } | |
38 | |
39 return failed; | |
40 } | |
41 } | |
42 } |