annotate api/Objects/ArmyCategory.cs @ 296:ed5e6d92ecd9

Re #323: WarFoundry.API - SystemStats cannot remove stat Remove code didn't fully remove stat, this has been fixed and tested
author Tsudico
date Sat, 18 Dec 2010 22:34:32 +0000
parents 938409fc24cc
children 92d10b06ab0f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 89
diff changeset
1 // This file (ArmyCategory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
2 //
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 89
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.
15
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>
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
14 public class ArmyCategory : WarFoundryObject, ICostedWarFoundryObject
82
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;
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
22 public event ObjectAddDelegate UnitAdded;
147
938409fc24cc Fixes #175: Add attribute to schema to define which stats set to use
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
23 public event ObjectRemoveDelegate UnitRemoved;
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
24 public event FailedUnitRequirementDelegate FailedRequirement;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
25 public event DoubleValChangedDelegate PointsValueChanged;
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;
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
77 TotalPoints+= unit.Points;
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;
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
86 TotalPoints-= unit.Points;
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
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
116 [Obsolete("Use Points instead")]
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
117 public double PointsTotal
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
118 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
119 get { return TotalPoints; }
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
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
122 public double Points
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
123 {
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
124 get { return TotalPoints; }
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
125 }
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
126
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
127 private void PointsValueChangedHandler(WarFoundryObject obj, double oldVal, double newVal)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
128 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
129 if (obj is Unit)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
130 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
131 double diff = newVal - oldVal;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
132 TotalPoints+= diff;
89
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
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
136 protected void OnUnitAdded(Unit unit)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
137 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
138 OnUnitAdded(unit, null);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
139 }
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 protected void OnUnitAdded(Unit unit, List<FailedUnitRequirement> failedReqs)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
142 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
143 if (UnitAdded != null)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
144 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
145 UnitAdded(unit);
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 if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
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 FailedRequirement(failedReqs);
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
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
154 protected void OnUnitRemoved(Unit unit)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
155 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
156 OnUnitRemoved(unit, null);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
157 }
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 protected void OnUnitRemoved(Unit unit, List<FailedUnitRequirement> failedReqs)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
160 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
161 if (UnitRemoved != null)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
162 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
163 UnitRemoved(unit);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
164 }
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
165
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
166 if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
167 {
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
168 FailedRequirement(failedReqs);
cb3759c3ea19 * Code clean-up (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
169 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
170 }
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 protected virtual void OnPointsValueChanged(double oldValue, double newValue)
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 if (PointsValueChanged!=null)
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 PointsValueChanged(this, 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
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
180 protected void cat_NameChanged(WarFoundryObject obj, string oldValue, string newValue)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
181 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
182 OnNameChanged(oldValue, newValue);
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
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
185 public int GetPointsPercentage()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
186 {
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
187 return (int)Math.Round((Points / ParentArmy.MaxPoints) * 100, 0);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
188 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
189 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
190 }