comparison API/Requirements/AbstractUnitRequirement.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 (AbstractUnitRequirement.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.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 }