15
|
1 // This file (RequirementOR.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
|
|
2 //
|
|
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.
|
|
4
|
0
|
5 using System;
|
|
6 using System.Collections.Generic;
|
|
7 using IBBoard.Lang;
|
|
8 using IBBoard.WarFoundry.API.Objects;
|
|
9
|
|
10 namespace IBBoard.WarFoundry.API.Requirements
|
|
11 {
|
|
12 /// <summary>
|
|
13 /// Summary description for UnitRequirementOR.
|
|
14 /// </summary>
|
|
15 public class RequirementOR : AbstractRequirement
|
|
16 {
|
|
17 private static string or;
|
|
18
|
|
19 static RequirementOR()
|
|
20 {
|
|
21 or = Translation.GetTranslation("requirement_or", true);
|
|
22
|
|
23 if (or == null)
|
|
24 {
|
|
25 or = "{0} or {1}";
|
|
26 }
|
|
27 }
|
|
28
|
|
29 private AbstractRequirement reqA, reqB;
|
|
30
|
|
31 public RequirementOR(AbstractRequirement requirementA, AbstractRequirement requirementB)
|
|
32 {
|
|
33 reqA = requirementA;
|
|
34 reqB = requirementB;
|
|
35 }
|
|
36
|
|
37 public override AbstractFailedRequirement CanAddToWarFoundryObject(WarFoundryObject obj)
|
|
38 {
|
|
39 FailedRequirement failed = null;
|
|
40
|
|
41 if (reqA.CanAddToWarFoundryObject(obj) !=null && reqB.CanAddToWarFoundryObject(obj)!=null)
|
|
42 {
|
|
43 failed = new FailedRequirement(this);
|
|
44 }
|
|
45
|
|
46 return failed;
|
|
47 }
|
|
48
|
|
49 public override AbstractFailedRequirement CanRemoveFromWarFoundryObject(WarFoundryObject obj)
|
|
50 {
|
|
51 FailedRequirement failed = null;
|
|
52
|
|
53 if (reqA.CanRemoveFromWarFoundryObject(obj)!=null && reqB.CanRemoveFromWarFoundryObject(obj)!=null)
|
|
54 {
|
|
55 failed = new FailedRequirement(this);
|
|
56 }
|
|
57
|
|
58 return failed;
|
|
59 }
|
|
60
|
|
61 public override string Description
|
|
62 {
|
|
63 get { return String.Format(or, reqA.Description, reqB.Description); }
|
|
64 }
|
|
65 }
|
|
66 }
|