Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Requirements/AbstractArmyRequirement.cs @ 323:8a64b36d36b8
Re #324: Add saving of Race and System data to files
* As per GameSystem changes for using existing code:
* Make XML creation method public
* Make sure we're encoding in UTF-8
* Implement saving method for Army
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 09 Mar 2011 20:59:34 +0000 |
parents | 2f3cafb69799 |
children |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
1 // This file (AbstractArmyRequirement.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 System.Collections.Generic; | |
7 using IBBoard.WarFoundry.API.Objects; | |
8 | |
9 | |
10 namespace IBBoard.WarFoundry.API.Requirements | |
11 { | |
12 /// <summary> | |
13 /// Abstract class for any requirement for adding an object to an army, e.g. adding units. | |
14 /// </summary> | |
15 public abstract class AbstractArmyRequirement : AbstractRequirement | |
16 { | |
17 protected abstract AbstractFailedRequirement CanAddToArmy(Army army); | |
18 protected abstract AbstractFailedRequirement CanRemoveFromArmy(Army army); | |
19 | |
20 public override AbstractFailedRequirement CanAddToWarFoundryObject (WarFoundryObject obj) | |
21 { | |
22 AbstractFailedRequirement fail = null; | |
23 | |
24 if (obj is Army) | |
25 { | |
26 fail = CanAddToArmy((Army)obj); | |
27 } | |
28 else | |
29 { | |
30 fail = new FailedRequirement(this); | |
31 } | |
32 | |
33 return fail; | |
34 } | |
35 | |
36 public override AbstractFailedRequirement CanRemoveFromWarFoundryObject (WarFoundryObject obj) | |
37 { | |
38 AbstractFailedRequirement fail = null; | |
39 | |
40 if (obj is Army) | |
41 { | |
42 fail = CanRemoveFromArmy((Army)obj); | |
43 } | |
44 else | |
45 { | |
46 fail = new FailedRequirement(this); | |
47 } | |
48 | |
49 return fail; | |
50 } | |
51 } | |
52 } |