Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/WarFoundryCore.cs @ 38:548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
* Remove Choices and Base/Increment from code
Re #47: Remove magic numbers
* Replace "-1" magic number with WarFoundryCore.INFINITY
* Use INFINITY instead of -1 in code
* Use INF in schemas instead of -1
* Handle and parse INF as a special value in XML Factory
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 19 Mar 2009 20:11:07 +0000 |
parents | 306558904c2a |
children | 3ea0ab04352b |
rev | line source |
---|---|
15 | 1 // This file (WarFoundryCore.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. |
0 | 2 // |
15 | 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. |
0 | 4 |
5 using System; | |
6 using IBBoard.Logging; | |
7 using IBBoard.WarFoundry.API.Objects; | |
8 | |
9 namespace IBBoard.WarFoundry.API | |
10 { | |
11 public class WarFoundryCore | |
12 { | |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
13 public static readonly int INFINITY = -1; |
0 | 14 public static event GameSystemChangedDelegate GameSystemChanged; |
15 public static event ArmyChangedDelegate ArmyChanged; | |
16 | |
17 private static GameSystem system; | |
18 private static Army currentArmy; | |
19 | |
20 public static GameSystem CurrentGameSystem | |
21 { | |
22 get { return system; } | |
23 set | |
24 { | |
25 if (system==null || !system.Equals(value)) | |
26 { | |
27 GameSystem oldSystem = system; | |
28 system = value; | |
29 | |
30 if (system==null) | |
31 { | |
32 LogNotifier.Debug(typeof(WarFoundryCore), "Game system set to null"); | |
33 } | |
34 else | |
35 { | |
36 LogNotifier.DebugFormat(typeof(WarFoundryCore), "Game system set to {0} with ID {1}", system.Name, system.ID); | |
37 } | |
38 | |
39 if (GameSystemChanged!=null) | |
40 { | |
41 GameSystemChanged(oldSystem, system); | |
42 } | |
43 | |
44 //If we've changed the game system then we can't keep the current army | |
45 CurrentArmy = null; | |
46 } | |
47 } | |
48 } | |
49 | |
50 public static Army CurrentArmy | |
51 { | |
52 get { return currentArmy; } | |
53 set | |
54 { | |
55 if (currentArmy==null || !currentArmy.Equals(value)) | |
56 { | |
57 /*if (currentArmy!=null) | |
58 { | |
59 currentArmy.UnitAdded-= UnitAddedMethod; | |
60 currentArmy.UnitRemoved-= UnitRemovedMethod; | |
61 currentArmy.PointsValueChanged-= PointsValueChangedMethod; | |
62 currentArmy.FailedRequirement-=FailedUnitRequirementMethod; | |
63 }*/ | |
64 Army oldArmy = currentArmy; | |
65 currentArmy = value; | |
66 | |
67 if (currentArmy!=null) | |
68 { | |
69 CurrentGameSystem = currentArmy.GameSystem; //Set the game system in case the new army is from a different system | |
70 } | |
71 | |
72 /*if (currentArmy!=null) | |
73 { | |
74 currentArmy.UnitAdded+= UnitAddedMethod; | |
75 currentArmy.UnitRemoved+= UnitRemovedMethod; | |
76 currentArmy.PointsValueChanged+= PointsValueChangedMethod; | |
77 currentArmy.FailedRequirement+=FailedUnitRequirementMethod; | |
78 }*/ | |
79 | |
80 if (ArmyChanged!=null) | |
81 { | |
82 ArmyChanged(oldArmy, currentArmy); | |
83 } | |
84 } | |
85 } | |
86 } | |
87 } | |
88 } |