0
|
1 // Requirement.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 System.Collections.Generic;
|
|
23 using IBBoard.WarFoundry.API.Objects;
|
|
24
|
|
25
|
|
26 namespace IBBoard.WarFoundry.API.Requirements
|
|
27 {
|
|
28 /// <summary>
|
|
29 /// Abstract class for any requirement for adding an object to an army, e.g. adding units.
|
|
30 /// </summary>
|
|
31 public abstract class AbstractArmyRequirement : AbstractRequirement
|
|
32 {
|
|
33 protected abstract AbstractFailedRequirement CanAddToArmy(Army army);
|
|
34 protected abstract AbstractFailedRequirement CanRemoveFromArmy(Army army);
|
|
35
|
|
36 public override AbstractFailedRequirement CanAddToWarFoundryObject (WarFoundryObject obj)
|
|
37 {
|
|
38 AbstractFailedRequirement fail = null;
|
|
39
|
|
40 if (obj is Army)
|
|
41 {
|
|
42 fail = CanAddToArmy((Army)obj);
|
|
43 }
|
|
44 else
|
|
45 {
|
|
46 fail = new FailedRequirement(this);
|
|
47 }
|
|
48
|
|
49 return fail;
|
|
50 }
|
|
51
|
|
52 public override AbstractFailedRequirement CanRemoveFromWarFoundryObject (WarFoundryObject obj)
|
|
53 {
|
|
54 AbstractFailedRequirement fail = null;
|
|
55
|
|
56 if (obj is Army)
|
|
57 {
|
|
58 fail = CanRemoveFromArmy((Army)obj);
|
|
59 }
|
|
60 else
|
|
61 {
|
|
62 fail = new FailedRequirement(this);
|
|
63 }
|
|
64
|
|
65 return fail;
|
|
66 }
|
|
67 }
|
|
68 }
|