Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Objects/Army.cs @ 423:314b8b8bf4f1
* Give Army objects a sensible default name, as we've been doing in UI
* Make name generation method static so that UI can use it
* Fire name change event when we change points with default name in case points were used in name
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 12 Oct 2011 20:39:28 +0100 |
parents | 3f297a60db1e |
children | d992758b0150 |
comparison
equal
deleted
inserted
replaced
422:87f4710b7f8c | 423:314b8b8bf4f1 |
---|---|
9 using System.Xml; | 9 using System.Xml; |
10 using IBBoard.WarFoundry.API; | 10 using IBBoard.WarFoundry.API; |
11 using IBBoard.WarFoundry.API.Factories; | 11 using IBBoard.WarFoundry.API.Factories; |
12 using ICSharpCode.SharpZipLib.Zip; | 12 using ICSharpCode.SharpZipLib.Zip; |
13 using IBBoard.WarFoundry.API.Objects.Requirement; | 13 using IBBoard.WarFoundry.API.Objects.Requirement; |
14 using IBBoard.Lang; | |
14 | 15 |
15 namespace IBBoard.WarFoundry.API.Objects | 16 namespace IBBoard.WarFoundry.API.Objects |
16 { | 17 { |
17 /// <summary> | 18 /// <summary> |
18 /// Summary description for Army. | 19 /// Summary description for Army. |
19 /// </summary> | 20 /// </summary> |
20 public class Army : WarFoundryLoadedObject, ICostedWarFoundryObject | 21 public class Army : WarFoundryLoadedObject, ICostedWarFoundryObject |
21 { | 22 { |
23 public static string GenerateDefaultName(Race race, int points, string ptsAbbrev) | |
24 { | |
25 return String.Format(race.ArmyDefaultName, Translation.GetTranslation("armySizePts", "{0}{1}", points, ptsAbbrev)); | |
26 } | |
27 | |
22 //private GameSystem system; | 28 //private GameSystem system; |
23 private Race armyRace; | 29 private Race armyRace; |
24 private int maxPoints; | 30 private int maxPoints; |
25 private double pointsTotal; | 31 private double pointsTotal; |
26 private Dictionary<Category, ArmyCategory> categories; | 32 private Dictionary<Category, ArmyCategory> categories; |
39 { | 45 { |
40 armyRace = race; | 46 armyRace = race; |
41 Name = armyName; | 47 Name = armyName; |
42 maxPoints = maxArmyPoints; | 48 maxPoints = maxArmyPoints; |
43 PointsValueChangedMethod = new DoubleValChangedDelegate(PointsValueChangedHandler); | 49 PointsValueChangedMethod = new DoubleValChangedDelegate(PointsValueChangedHandler); |
50 } | |
51 | |
52 protected override string DefaultName() | |
53 { | |
54 return Army.GenerateDefaultName(Race, MaxPoints, GameSystem.GetPointsAbbrev(MaxPoints)); | |
44 } | 55 } |
45 | 56 |
46 public ArmyCategory GetCategory(Category cat) | 57 public ArmyCategory GetCategory(Category cat) |
47 { | 58 { |
48 ArmyCategory armyCat = null; | 59 ArmyCategory armyCat = null; |
189 | 200 |
190 if (MaxPointsValueChanged != null) | 201 if (MaxPointsValueChanged != null) |
191 { | 202 { |
192 MaxPointsValueChanged(this, oldPoints, maxPoints); | 203 MaxPointsValueChanged(this, oldPoints, maxPoints); |
193 } | 204 } |
205 | |
206 if (HasDefaultName()) | |
207 { | |
208 OnNameChanged("", Name); | |
209 } | |
194 } | 210 } |
195 } | 211 } |
196 } | 212 } |
197 | 213 |
198 private void PointsValueChangedHandler(WarFoundryObject obj, double oldVal, double newVal) | 214 private void PointsValueChangedHandler(WarFoundryObject obj, double oldVal, double newVal) |