annotate API/Objects/UnitEquipmentItem.cs @ 448:dbd779cdc0f9

Re #350: Add requirement to allow N of unit for specific other units * Fix limit checking when "limited count" is not 1 (e.g. "need 2 for every 3")
author IBBoard <dev@ibboard.co.uk>
date Fri, 23 Dec 2011 15:36:06 +0000
parents 7e95b880f9cc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.CustomMath;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.Limits;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Util;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.Lang;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 //using IBBoard.WarFoundry.API.Objects;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 namespace IBBoard.WarFoundry.API.Objects
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 /// Summary description for UnitEquipmentItem.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 public class UnitEquipmentItem : WarFoundryObject
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 private EquipmentItem item;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 private bool required;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 private bool roundUp;
430
7e95b880f9cc Re #356: Stack overflow with certain equipment limits
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
22 private double costMultiplier = 1;
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 private RoundType roundType;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 private string[] mutexGroups;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 private UnitType unitType;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 private string slotName = "";
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 private ILimit minLimit;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 private ILimit maxLimit;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 : this(equipmentItem, equipmentFor, new string[0])
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 //Do nothing extra
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 item = equipmentItem;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 unitType = equipmentFor;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 this.mutexGroups = mutexGroups;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 unitType.AddEquipmentItem(this);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 public override string Name
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 get
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 return item.Name;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 set
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 base.Name = value;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 public override string ID
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 get
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 set
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 base.ID = value;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 public string EquipmentItemID
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 get { return item.ID; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 public double Cost
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 get
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 public double CostMultiplier
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82 get { return costMultiplier; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 set
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 costMultiplier = value;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 public RoundType CostRoundType
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 get { return roundType; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 set
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 roundType = value;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 public bool IsRequired
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 get { return required; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 set { required = value; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 public bool RoundNumberUp
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 get { return roundUp; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 set { roundUp = value; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 public GameSystem GameSystem
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 get { return EquipmentItem.GameSystem; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 public String[] MutexGroups
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 get { return (string[]) mutexGroups.Clone(); }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 public UnitType EquipmentForUnit
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 get { return unitType; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 public bool IsRatioLimit
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 get { return MinLimit is IPercentageLimit && MaxLimit is IPercentageLimit; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 /// Gets the Limit object for the minimum number of items that can be taken
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 public ILimit MinLimit
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 get
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 ILimit limit = minLimit;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 if (limit == null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 if (maxLimit != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 limit = maxLimit;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 else
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
147 limit = new SimpleRoundedPercentageLimit(100, false);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
149 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
151 return limit;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
152 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 set
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
154 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
155 if (value != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
156 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 minLimit = value;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163 /// Gets the Limit object for the maximum number of items that can be taken
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 public ILimit MaxLimit
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167 get
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 ILimit limit = maxLimit;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 if (limit == null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173 if (minLimit != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 limit = minLimit;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 else
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 limit = new SimpleRoundedPercentageLimit(100, false);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 return limit;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
184 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 set
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 if (value != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189 maxLimit = value;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
191 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
193
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
194 public EquipmentItem EquipmentItem
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
195 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
196 get { return item; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
197 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
198
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
199 public override string ToString()
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
200 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
201 return Translation.GetTranslation("UnitEquipmentItemName", "{0} ({1}{2} each)", Name, Cost, GameSystem.GetPointsAbbrev(Cost));
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204 public bool HasAlternatives()
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
205 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
206 if (MutexGroups.Length == 0)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
207 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
208 return false;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
209 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
210 else if (EquipmentForUnit == null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
211 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 return false;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
213 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214 else
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
215 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216 //If the number of items in the MutEx group is greater than one then it must be this item plus another
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
217 return EquipmentForUnit.GetEquipmentItemsByExclusionGroups(MutexGroups).Length > 1;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
219 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221 public string Description
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
223 get { return EquipmentItem.Description; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
224 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
225
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 public Race EquipmentForRace
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
227 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
228 get { return EquipmentItem.EquipmentForRace; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
229 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
230
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
231 public bool CanBeUsedWithItem(EquipmentItem item)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
232 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
233 return EquipmentItem.CanBeUsedWithItem(item);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
234 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
235
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
236 public string SlotName
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
237 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
238 get { return slotName; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
239 set
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
240 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
241 if (value != null && value != "")
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
242 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
243 slotName = value;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
244 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
245 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
246 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
247 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
248 }