Mercurial > repos > snowblizz-super-API-ideas
annotate api/WarFoundryCore.cs @ 393:b90db11edc64 default-army-size
Re #97: Default army size
* Merge accidental commit into "default name" branch into "default size" branch
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 13 Dec 2010 19:49:55 +0000 |
parents | 52cacdbcb001 |
children |
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 Army oldArmy = currentArmy; | |
0 | 58 |
129
52cacdbcb001
Fixes #126: First army load fails
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
59 if (value != null) |
0 | 60 { |
129
52cacdbcb001
Fixes #126: First army load fails
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
61 CurrentGameSystem = value.GameSystem; //Set the game system in case the new army is from a different system |
52cacdbcb001
Fixes #126: First army load fails
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
62 currentArmy = value; |
82 | 63 } |
129
52cacdbcb001
Fixes #126: First army load fails
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
64 else |
82 | 65 { |
129
52cacdbcb001
Fixes #126: First army load fails
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
66 currentArmy = null; |
52cacdbcb001
Fixes #126: First army load fails
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
67 } |
52cacdbcb001
Fixes #126: First army load fails
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
68 |
82 | 69 if (ArmyChanged!=null) |
70 { | |
71 ArmyChanged(oldArmy, currentArmy); | |
72 } | |
73 } | |
74 } | |
0 | 75 } |
76 } | |
77 } |