Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Requirements/UnitRequirementMaxNumber.cs @ 337:3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 03 Apr 2011 18:50:32 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
336:3631c1493c7f | 337:3c4a6403a88c |
---|---|
1 // This file (UnitRequirementMaxNumber.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2008, 2009 IBBoard. | |
2 // | |
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. | |
4 | |
5 using System; | |
6 using IBBoard.Lang; | |
7 using IBBoard.WarFoundry.API.Objects; | |
8 | |
9 namespace IBBoard.WarFoundry.API.Requirements | |
10 { | |
11 public class UnitRequirementMaxNumber : UnitRequirement | |
12 { | |
13 private int maxUnitCount; | |
14 | |
15 public UnitRequirementMaxNumber(UnitType type, int maxNumber) : base(type) | |
16 { | |
17 maxUnitCount = maxNumber; | |
18 } | |
19 | |
20 public override string Description | |
21 { | |
22 get { return Translation.GetTranslation("requirementUnitMaxNumber", "an army can contain up to {0} units of type {1}", maxUnitCount, unitType.Name); } | |
23 } | |
24 | |
25 protected override AbstractFailedRequirement CanAddToArmy (Army army, UnitType type) | |
26 { | |
27 FailedUnitRequirement failed = null; | |
28 | |
29 if (army.GetUnitTypeCount(type) >= maxUnitCount) | |
30 { | |
31 failed = new FailedUnitRequirement(this); | |
32 } | |
33 | |
34 return failed; | |
35 } | |
36 | |
37 protected override AbstractFailedRequirement CanRemoveFromArmy (Army army, UnitType type) | |
38 { | |
39 return null; | |
40 } | |
41 } | |
42 } |