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 {
|
|
13 public static event GameSystemChangedDelegate GameSystemChanged;
|
|
14 public static event ArmyChangedDelegate ArmyChanged;
|
|
15
|
|
16 private static GameSystem system;
|
|
17 private static Army currentArmy;
|
|
18
|
|
19 public static GameSystem CurrentGameSystem
|
|
20 {
|
|
21 get { return system; }
|
|
22 set
|
|
23 {
|
|
24 if (system==null || !system.Equals(value))
|
|
25 {
|
|
26 GameSystem oldSystem = system;
|
|
27 system = value;
|
|
28
|
|
29 if (system==null)
|
|
30 {
|
|
31 LogNotifier.Debug(typeof(WarFoundryCore), "Game system set to null");
|
|
32 }
|
|
33 else
|
|
34 {
|
|
35 LogNotifier.DebugFormat(typeof(WarFoundryCore), "Game system set to {0} with ID {1}", system.Name, system.ID);
|
|
36 }
|
|
37
|
|
38 if (GameSystemChanged!=null)
|
|
39 {
|
|
40 GameSystemChanged(oldSystem, system);
|
|
41 }
|
|
42
|
|
43 //If we've changed the game system then we can't keep the current army
|
|
44 CurrentArmy = null;
|
|
45 }
|
|
46 }
|
|
47 }
|
|
48
|
|
49 public static Army CurrentArmy
|
|
50 {
|
|
51 get { return currentArmy; }
|
|
52 set
|
|
53 {
|
|
54 if (currentArmy==null || !currentArmy.Equals(value))
|
|
55 {
|
|
56 /*if (currentArmy!=null)
|
|
57 {
|
|
58 currentArmy.UnitAdded-= UnitAddedMethod;
|
|
59 currentArmy.UnitRemoved-= UnitRemovedMethod;
|
|
60 currentArmy.PointsValueChanged-= PointsValueChangedMethod;
|
|
61 currentArmy.FailedRequirement-=FailedUnitRequirementMethod;
|
|
62 }*/
|
|
63 Army oldArmy = currentArmy;
|
|
64 currentArmy = value;
|
|
65
|
|
66 if (currentArmy!=null)
|
|
67 {
|
|
68 CurrentGameSystem = currentArmy.GameSystem; //Set the game system in case the new army is from a different system
|
|
69 }
|
|
70
|
|
71 /*if (currentArmy!=null)
|
|
72 {
|
|
73 currentArmy.UnitAdded+= UnitAddedMethod;
|
|
74 currentArmy.UnitRemoved+= UnitRemovedMethod;
|
|
75 currentArmy.PointsValueChanged+= PointsValueChangedMethod;
|
|
76 currentArmy.FailedRequirement+=FailedUnitRequirementMethod;
|
|
77 }*/
|
|
78
|
|
79 if (ArmyChanged!=null)
|
|
80 {
|
|
81 ArmyChanged(oldArmy, currentArmy);
|
|
82 }
|
|
83 }
|
|
84 }
|
|
85 }
|
|
86 }
|
|
87 }
|