Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate API/Objects/Army.cs @ 496:00d6cf940c3c
Re #420: Saved army does not save "contained" structure
* Add loading of nesting from .army files
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 01 Sep 2012 15:28:26 +0100 |
parents | aac77204ae0e |
children |
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 (Army.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 System.IO; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using System.Collections.Generic; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using System.Text; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 using System.Xml; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 using IBBoard.WarFoundry.API; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 using IBBoard.WarFoundry.API.Factories; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 using ICSharpCode.SharpZipLib.Zip; |
353 | 13 using IBBoard.WarFoundry.API.Objects.Requirement; |
423
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
14 using IBBoard.Lang; |
451
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
15 using IBBoard.Collections; |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 namespace IBBoard.WarFoundry.API.Objects |
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 /// <summary> |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 /// Summary description for Army. |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 /// </summary> |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 public class Army : WarFoundryLoadedObject, ICostedWarFoundryObject |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 { |
423
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
24 public static string GenerateDefaultName(Race race, int points, string ptsAbbrev) |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
25 { |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
26 return String.Format(race.ArmyDefaultName, Translation.GetTranslation("armySizePts", "{0}{1}", points, ptsAbbrev)); |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
27 } |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
28 |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 //private GameSystem system; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 private Race armyRace; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 private int maxPoints; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 private double pointsTotal; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 private Dictionary<Category, ArmyCategory> categories; |
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 event ObjectAddDelegate UnitAdded; |
413
3f297a60db1e
Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
36 public event ObjectRemoveDelegate UnitRemoved; |
3f297a60db1e
Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
37 public event IntValChangedDelegate MaxPointsValueChanged; |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 public event DoubleValChangedDelegate PointsValueChanged; |
424
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
39 public event MethodInvoker ArmyCompositionChanged; |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 private DoubleValChangedDelegate PointsValueChangedMethod; |
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 public Army(Race race, string armyName, int maxArmyPoints) : this(race, armyName, maxArmyPoints, null) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 { |
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 public Army(Race race, string armyName, int maxArmyPoints, ZipFile file) : base(armyName) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 armyRace = race; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 Name = armyName; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 maxPoints = maxArmyPoints; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 PointsValueChangedMethod = new DoubleValChangedDelegate(PointsValueChangedHandler); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 } |
423
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
53 |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
54 protected override string DefaultName() |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
55 { |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
56 return Army.GenerateDefaultName(Race, MaxPoints, GameSystem.GetPointsAbbrev(MaxPoints)); |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
57 } |
337
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 public ArmyCategory GetCategory(Category cat) |
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 ArmyCategory armyCat = null; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 ArmyCategories.TryGetValue(cat, out armyCat); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 return armyCat; |
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 private Dictionary<Category, ArmyCategory> ArmyCategories |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 get |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
70 if (categories == null) |
337
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 categories = new Dictionary<Category, ArmyCategory>(); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 Category[] raceCats = Race.Categories; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 ArmyCategory cat; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 int raceCatCount = raceCats.Length; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 for (int i = 0; i < raceCatCount; i++) |
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 Category raceCat = raceCats[i]; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 cat = new ArmyCategory(this, raceCat); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 categories[raceCat] = cat; |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
82 cat.PointsValueChanged += PointsValueChangedMethod; |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
83 cat.UnitAdded += new ObjectAddDelegate(Army_UnitAdded); |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
84 cat.UnitRemoved += new ObjectRemoveDelegate(Army_UnitRemoved); |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 } |
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 return categories; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 } |
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 public ArmyCategory[] Categories |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
94 get |
337
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 return DictionaryUtils.ToArray<Category, ArmyCategory>(ArmyCategories); |
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 } |
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 public Race Race |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 get { return armyRace; } |
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
105 public GameSystem GameSystem |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
106 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
107 get { return (armyRace != null ? armyRace.GameSystem : null); } |
337
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 protected void OnUnitAdded(Unit unit) |
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 if (UnitAdded != null) |
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 UnitAdded(unit); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
115 } |
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
118 protected void OnUnitRemoved(Unit unit) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
119 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
120 if (UnitRemoved != null) |
337
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 UnitRemoved(unit); |
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
126 private void OnPointsValueChanged(double oldValue, double newValue) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
127 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
128 if (PointsValueChanged != null) |
337
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 PointsValueChanged(this, oldValue, newValue); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
132 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
133 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 private double TotalPoints |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
136 get { return pointsTotal; } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
137 set |
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 double oldPoints = pointsTotal; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 pointsTotal = value; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
141 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
142 if (oldPoints != pointsTotal) |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
143 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 OnPointsValueChanged(oldPoints, pointsTotal); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
145 } |
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 } |
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 public double Points |
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 get { return TotalPoints; } |
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
154 public void AddUnit(Unit unit) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
155 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
156 Category category = unit.UnitType.MainCategory; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
157 AddUnit(unit, category); |
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 public void AddUnit(Unit unit, Category category) |
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 ArmyCategory armyCat = GetCategory(category); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
163 armyCat.AddUnit(unit); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 public void RemoveUnit(Unit unit) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
168 unit.Category.RemoveUnit(unit); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 } |
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 public Unit[] GetUnits(Category cat) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 { |
471
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
173 return GetUnits(GetCategory(cat)); |
337
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
176 public Unit[] GetUnits(ArmyCategory cat) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 return cat.GetUnits(); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 |
471
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
181 public Unit[] GetMainUnits(Category cat) |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
182 { |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
183 return GetMainUnits(GetCategory(cat)); |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
184 } |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
185 |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
186 public Unit[] GetMainUnits(ArmyCategory cat) |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
187 { |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
188 return cat.GetMainUnits(); |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
189 } |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
451
diff
changeset
|
190 |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
191 public Unit[] GetUnits() |
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 List<Unit> fullList = new List<Unit>(); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
194 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
195 foreach (ArmyCategory cat in Categories) |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
196 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
197 fullList.AddRange(cat.GetUnits()); |
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
200 return fullList.ToArray(); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
202 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
203 public Unit[] GetUnits(UnitType unitType) |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
204 { |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
205 List<Unit> fullList = new List<Unit>(); |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
206 |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
207 foreach (ArmyCategory cat in Categories) |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
208 { |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
209 fullList.AddRange(cat.GetUnits(unitType)); |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
210 } |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
211 |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
212 return fullList.ToArray(); |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
213 } |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
214 |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
215 public int MaxPoints |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
217 get { return maxPoints; } |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
218 set |
337
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 if (value > 0) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
221 { |
413
3f297a60db1e
Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
222 int oldPoints = maxPoints; |
3f297a60db1e
Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
223 maxPoints = value; |
3f297a60db1e
Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
224 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
225 if (MaxPointsValueChanged != null) |
413
3f297a60db1e
Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
226 { |
3f297a60db1e
Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
227 MaxPointsValueChanged(this, oldPoints, maxPoints); |
3f297a60db1e
Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
228 } |
423
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
229 |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
230 if (HasDefaultName()) |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
231 { |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
232 OnNameChanged("", Name); |
314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
IBBoard <dev@ibboard.co.uk>
parents:
413
diff
changeset
|
233 } |
337
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 } |
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 private void PointsValueChangedHandler(WarFoundryObject obj, double oldVal, double newVal) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
239 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
240 if (obj is ArmyCategory) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
241 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
242 double points = 0; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
243 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
244 foreach (ArmyCategory cat in Categories) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
245 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
246 points += cat.Points; |
337
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 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
249 TotalPoints = points; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
250 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
251 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
252 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
253 public int GetUnitTypeCount(UnitType unitType) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
254 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
255 int count = 0; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
256 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
257 foreach (ArmyCategory cat in Categories) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
258 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
259 count += cat.GetUnitTypeCount(unitType); |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
260 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
261 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
262 return count; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
263 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
264 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
265 private void Army_UnitAdded(WarFoundryObject val) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
266 { |
424
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
267 Unit unit = (Unit)val; |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
268 OnUnitAdded(unit); |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
269 OnArmyCompositionChanged(); |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
270 unit.UnitEquipmentAmountChanged += HandleUnitUnitEquipmentAmountChanged; |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
271 unit.UnitSizeChanged += HandleUnitUnitSizeChanged; |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
272 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
273 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
274 private void Army_UnitRemoved(WarFoundryObject val) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
275 { |
424
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
276 Unit unit = (Unit)val; |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
277 OnUnitRemoved(unit); |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
278 OnArmyCompositionChanged(); |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
279 unit.UnitEquipmentAmountChanged -= HandleUnitUnitEquipmentAmountChanged; |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
280 unit.UnitSizeChanged -= HandleUnitUnitSizeChanged; |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
281 } |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
282 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
283 private void HandleUnitUnitEquipmentAmountChanged(WarFoundryObject obj, double oldValue, double newValue) |
424
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
284 { |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
285 OnArmyCompositionChanged(); |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
286 } |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
287 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
288 private void HandleUnitUnitSizeChanged(WarFoundryObject obj, int oldValue, int newValue) |
424
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
289 { |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
290 OnArmyCompositionChanged(); |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
291 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
292 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
478
diff
changeset
|
293 public ICollection<IRequirement> GetRequirements() |
353 | 294 { |
295 return Race.GetRequirements(); | |
296 } | |
424
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
297 |
451
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
298 public ICollection<IRequirement> GetAddingUnitRequirements(UnitType addingType) |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
299 { |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
300 Unit[] units = GetUnits(); |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
301 SimpleSet<UnitType> unitTypes = new SimpleSet<UnitType>(); |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
302 unitTypes.Add(addingType); |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
303 |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
304 foreach (Unit unit in units) |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
305 { |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
306 unitTypes.Add(unit.UnitType); |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
307 } |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
308 |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
309 SimpleSet<IRequirement> requirements = new SimpleSet<IRequirement>(); |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
310 |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
311 foreach (UnitType unitType in unitTypes) |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
312 { |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
313 requirements.AddRange(unitType.GetRequirements()); |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
314 } |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
315 |
478
e4e2a85604b6
* Change back to no type casting - MonoDevelop suggested it, but our code balks in unit tests with it
IBBoard <dev@ibboard.co.uk>
parents:
476
diff
changeset
|
316 return requirements; |
451
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
317 } |
676f5ce04176
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
424
diff
changeset
|
318 |
424
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
319 internal void OnArmyCompositionChanged() |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
320 { |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
321 if (ArmyCompositionChanged != null) |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
322 { |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
323 ArmyCompositionChanged(); |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
324 } |
d992758b0150
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
423
diff
changeset
|
325 } |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
326 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
327 } |