15
|
1 // This file (AbstractUnitRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
|
0
|
2 //
|
15
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL 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 }
|