annotate api/Objects/ArmyCategory.cs @ 101:f7b9423c2a5a

Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly. This revision will be broken for the WinForms UI, but as MonoDevelop/eSVN don't have a way of committing multiple projects in one go it can't be helped (Eclipse's Team Sync view could handle it) Fixes #122: Make usage of percentage or ratio common * All usage of ratio amounts for equipment items should now assume percentage * Properly calculate number taken for ratio selection (divide by 0 now we're using percentages) Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts * Added extra commands that differentiate between ratio and absolute amounts Fixes #120: Numeric limit equipment items show large percentages * Now made formatting treat ratios as percentages (don't multiply by 100) * Move string formatting to UnitEquipmentItem...Selection classes * Add method to Unit to say whether an equipment item is a numeric or ratio amount
author IBBoard <dev@ibboard.co.uk>
date Thu, 13 Aug 2009 21:09:20 +0000
parents cb3759c3ea19
children 2f3cafb69799
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
1 // This file (ArmyCategory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
2 //
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
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.
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
4
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
5 using System;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.Collections.Generic;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
7 using IBBoard.WarFoundry.API.Requirements;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
8
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
10 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
11 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
12 /// Summary description for ArmyCategory.
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
13 /// </summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
14 public class ArmyCategory : WarFoundryObject
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
15 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
16 private Category category;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
17 private Army parentArmy;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
18 private double pointsTotal;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
19 private List<Unit> units;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
20 private Dictionary<string, int> unitTypes;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
21 private DoubleValChangedDelegate PointsValueChangedMethod;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
22 public event DoubleValChangedDelegate PointsValueChanged;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
23 public event ObjectAddDelegate UnitAdded;
89
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
24 public event ObjectRemoveDelegate UnitRemoved;
83
89cc29b4c012 Re #90: Stop new units showing up twice
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
25 public event FailedUnitRequirementDelegate FailedRequirement;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
26
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
27 public ArmyCategory(Army army, Category cat) : base()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
28 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
29 parentArmy = army;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
30 category = cat;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
31 cat.NameChanged+=new StringValChangedDelegate(cat_NameChanged);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
32 PointsValueChangedMethod = new DoubleValChangedDelegate(PointsValueChangedHandler);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
33 units = new List<Unit>();
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
34 unitTypes = new Dictionary<string,int>();
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
35 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
36
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
37 public Category Category
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
38 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
39 get { return category; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
40 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
41
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
42 public Army ParentArmy
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
43 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
44 get { return parentArmy; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
45 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
46
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
47 public override string ID
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
48 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
49 get
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
50 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
51 return Category.ID;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
52 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
53 set
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
54 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
55 Category.ID = value;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
56 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
57 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
58
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
59 public override string Name
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
60 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
61 get { return category.Name; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
62 set
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
63 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
64 category.Name = value;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
65 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
66 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
67
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
68 internal void AddUnit(Unit unit)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
69 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
70 List<FailedUnitRequirement> failedReqs = ParentArmy.CanAddUnit(unit);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
71 units.Add(unit);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
72 unit.Category = this;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 unit.PointsValueChanged+= PointsValueChangedMethod;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
74 int unitTypeCount;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
75 unitTypes.TryGetValue(unit.UnitType.ID, out unitTypeCount);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
76 unitTypes[unit.UnitType.ID] = (int)unitTypeCount + 1;
58
e53ed2d613a1 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
77 TotalPoints+= unit.PointsValue;
83
89cc29b4c012 Re #90: Stop new units showing up twice
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
78 OnUnitAdded(unit, failedReqs);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
79 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
80
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
81 internal void RemoveUnit(Unit unit)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
82 {
83
89cc29b4c012 Re #90: Stop new units showing up twice
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
83 List<FailedUnitRequirement> failedReqs = ParentArmy.CanRemoveUnit(unit);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
84 units.Remove(unit);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
85 unitTypes[unit.UnitType.ID] = ((int)unitTypes[unit.UnitType.ID])-1;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
86 TotalPoints-= unit.PointsValue;
58
e53ed2d613a1 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
87 unit.PointsValueChanged-= PointsValueChangedMethod;
83
89cc29b4c012 Re #90: Stop new units showing up twice
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
88 OnUnitRemoved(unit, failedReqs);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
89 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
90
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
91 public int GetUnitTypeCount(UnitType unitType)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
92 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
93 return unitTypes.ContainsKey(unitType.ID) ? (int)unitTypes[unitType.ID] : 0;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
94 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
95
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
96 public Unit[] GetUnits()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
97 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
98 return units.ToArray();
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
99 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
100
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
101 private double TotalPoints
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
102 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
103 get { return pointsTotal; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
104 set
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
105 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
106 double oldVal = pointsTotal;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
107 pointsTotal = value;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
108
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
109 if (oldVal!=pointsTotal)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
110 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
111 OnPointsValueChanged(oldVal, pointsTotal);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
112 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
113 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
114 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
115
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
116 public double PointsTotal
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
117 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
118 get { return TotalPoints; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
119 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
120
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
121 private void PointsValueChangedHandler(WarFoundryObject obj, double oldVal, double newVal)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
122 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
123 if (obj is Unit)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
124 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
125 double diff = newVal - oldVal;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
126 TotalPoints+= diff;
89
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
127 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
128 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
129
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
130 protected void OnUnitAdded(Unit unit)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
131 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
132 OnUnitAdded(unit, null);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
133 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
134
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
135 protected void OnUnitAdded(Unit unit, List<FailedUnitRequirement> failedReqs)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
136 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
137 if (UnitAdded != null)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
138 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
139 UnitAdded(unit);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
140 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
141
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
142 if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
143 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
144 FailedRequirement(failedReqs);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
145 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
146 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
147
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
148 protected void OnUnitRemoved(Unit unit)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
149 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
150 OnUnitRemoved(unit, null);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
151 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
152
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
153 protected void OnUnitRemoved(Unit unit, List<FailedUnitRequirement> failedReqs)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
154 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
155 if (UnitRemoved != null)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
156 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
157 UnitRemoved(unit);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
158 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
159
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
160 if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
161 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
162 FailedRequirement(failedReqs);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
163 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
164 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
165
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
166 protected virtual void OnPointsValueChanged(double oldValue, double newValue)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
167 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
168 if (PointsValueChanged!=null)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
169 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
170 PointsValueChanged(this, oldValue, newValue);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
171 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
172 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
173
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
174 protected void cat_NameChanged(WarFoundryObject obj, string oldValue, string newValue)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
175 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
176 OnNameChanged(oldValue, newValue);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
177 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
178
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
179 public int GetPointsPercentage()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
180 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
181 return (int)Math.Round((PointsTotal / ParentArmy.MaxPoints) * 100, 0);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
182 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
183 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
184 }