Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Requirements/AbstractUnitRequirement.cs @ 194:1412a42190a1
* Fix mutex group clash checking
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 30 Oct 2009 20:23:03 +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 (AbstractUnitRequirement.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 /// <summary> | |
11 /// Base abstract class for all requirements related to adding/removing something from a Unit (e.g. adding equipment or abilities) | |
12 /// </summary> | |
13 public abstract class AbstractUnitRequirement : AbstractRequirement | |
14 { | |
15 protected abstract AbstractFailedRequirement CanAddToUnit(Unit unit); | |
16 protected abstract AbstractFailedRequirement CanRemoveFromUnit(Unit unit); | |
17 | |
18 public override AbstractFailedRequirement CanAddToWarFoundryObject (WarFoundryObject obj) | |
19 { | |
20 AbstractFailedRequirement fail = null; | |
21 | |
22 if (obj is Unit) | |
23 { | |
24 fail = CanAddToUnit((Unit)obj); | |
25 } | |
26 else | |
27 { | |
28 fail = new FailedRequirement(this); | |
29 } | |
30 | |
31 return fail; | |
32 } | |
33 | |
34 public override AbstractFailedRequirement CanRemoveFromWarFoundryObject (WarFoundryObject obj) | |
35 { | |
36 AbstractFailedRequirement fail = null; | |
37 | |
38 if (obj is Unit) | |
39 { | |
40 fail = CanRemoveFromUnit((Unit)obj); | |
41 } | |
42 else | |
43 { | |
44 fail = new FailedRequirement(this); | |
45 } | |
46 | |
47 return fail; | |
48 } | |
49 } | |
50 } |