comparison api/Requirements/AbstractUnitRequirement.cs @ 0:520818033bb6

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 306558904c2a
comparison
equal deleted inserted replaced
-1:000000000000 0:520818033bb6
1 // AbstractUnitRequirement.cs
2 //
3 // Copyright (C) 2008 IBBoard
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License version 2.1 of the License as published by the Free
8 // Software Foundation.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 //
19 //
20
21 using System;
22 using IBBoard.WarFoundry.API.Objects;
23
24 namespace IBBoard.WarFoundry.API.Requirements
25 {
26 /// <summary>
27 /// Base abstract class for all requirements related to adding/removing something from a Unit (e.g. adding equipment or abilities)
28 /// </summary>
29 public abstract class AbstractUnitRequirement : AbstractRequirement
30 {
31 protected abstract AbstractFailedRequirement CanAddToUnit(Unit unit);
32 protected abstract AbstractFailedRequirement CanRemoveFromUnit(Unit unit);
33
34 public override AbstractFailedRequirement CanAddToWarFoundryObject (WarFoundryObject obj)
35 {
36 AbstractFailedRequirement fail = null;
37
38 if (obj is Unit)
39 {
40 fail = CanAddToUnit((Unit)obj);
41 }
42 else
43 {
44 fail = new FailedRequirement(this);
45 }
46
47 return fail;
48 }
49
50 public override AbstractFailedRequirement CanRemoveFromWarFoundryObject (WarFoundryObject obj)
51 {
52 AbstractFailedRequirement fail = null;
53
54 if (obj is Unit)
55 {
56 fail = CanRemoveFromUnit((Unit)obj);
57 }
58 else
59 {
60 fail = new FailedRequirement(this);
61 }
62
63 return fail;
64 }
65 }
66 }