Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/WarFoundryCore.cs @ 121:53654e938982
Re #54: Add army file loading
* Add equipment loading (currently fails because of ID mismatch - in the test race we create UnitEquipmentItems with the ID Empire1equip1 but in the army saving/loading we use equip1)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 23 Aug 2009 11:05:37 +0000 |
parents | 2f3cafb69799 |
children | 52cacdbcb001 |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1 // This file (WarFoundryCore.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard. |
0 | 2 // |
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
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. |
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; |
82 | 14 public static event GameSystemChangedDelegate GameSystemChanged; |
0 | 15 public static event ArmyChangedDelegate ArmyChanged; |
16 | |
17 private static GameSystem system; | |
18 private static Army currentArmy; | |
19 | |
82 | 20 public static GameSystem CurrentGameSystem |
21 { | |
22 get { return system; } | |
23 set | |
24 { | |
25 if (system==null || !system.Equals(value)) | |
0 | 26 { |
82 | 27 GameSystem oldSystem = system; |
0 | 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); | |
82 | 37 } |
38 | |
39 if (GameSystemChanged!=null) | |
40 { | |
41 GameSystemChanged(oldSystem, system); | |
0 | 42 } |
43 | |
44 //If we've changed the game system then we can't keep the current army | |
82 | 45 CurrentArmy = null; |
46 } | |
47 } | |
0 | 48 } |
49 | |
82 | 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; | |
0 | 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 | |
82 | 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 } | |
0 | 86 } |
87 } | |
88 } |