Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Requirements/UnitExclusion.cs @ 162:624422e91a1c
Re #192: Improve "clean coding" practice
* Make Equipment util class public
* Remove use of obsolete method
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Oct 2009 15:52:15 +0000 |
parents | 2f3cafb69799 |
children |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1 // This file (UnitExclusion.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2008, 2009 IBBoard. |
15 | 2 // |
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
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. |
15 | 4 |
82 | 5 using System; |
0 | 6 using System.Text; |
82 | 7 using IBBoard.WarFoundry.API.Objects; |
8 | |
9 namespace IBBoard.WarFoundry.API.Requirements | |
10 { | |
11 /// <summary> | |
12 /// Summary description for UnitMaxNumberRequirement. | |
13 /// </summary> | |
14 public class UnitExclusion : FailedUnitRequirement | |
15 { | |
16 private string unitList; | |
17 private UnitType type; | |
18 | |
19 public UnitExclusion(UnitRequirement req, UnitType unitType, UnitType[] excludingTypes) : base(req) | |
20 { | |
21 type = unitType; | |
22 | |
23 if (excludingTypes.Length > 1) | |
24 { | |
25 StringBuilder sb = new StringBuilder(excludingTypes[0].Name); | |
26 | |
27 for (int i = 1; i<excludingTypes.Length; i++) | |
28 { | |
29 sb.Append(", "+excludingTypes[i].Name); | |
30 } | |
31 | |
32 unitList = sb.ToString(); | |
33 } | |
34 else | |
35 { | |
36 unitList = excludingTypes[0].Name; | |
37 } | |
38 } | |
39 | |
40 public override string Description | |
41 { | |
42 get { return "The army cannot have any of the following units to include a unit of type "+type.Name+": "+unitList; } | |
43 } | |
44 } | |
45 } |