comparison API/WarFoundryCore.cs @ 337:3c4a6403a88c

* Fix capitalisation so that new files are in the namespace no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sun, 03 Apr 2011 18:50:32 +0000
parents
children c32bb2a53b87
comparison
equal deleted inserted replaced
336:3631c1493c7f 337:3c4a6403a88c
1 // This file (WarFoundryCore.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
2 //
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.
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 readonly int INFINITY = -1;
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 Army oldArmy = currentArmy;
58
59 if (value != null)
60 {
61 CurrentGameSystem = value.GameSystem; //Set the game system in case the new army is from a different system
62 currentArmy = value;
63 }
64 else
65 {
66 currentArmy = null;
67 }
68
69 if (ArmyChanged!=null)
70 {
71 ArmyChanged(oldArmy, currentArmy);
72 }
73 }
74 }
75 }
76 }
77 }