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