Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Objects/SystemStats.cs @ 67:e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
* Clean up stat loading for game systems and unit types
* Delete rogue character that stopped code compiling
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 25 Apr 2009 14:59:23 +0000 |
parents | 306558904c2a |
children | 3ea0ab04352b |
rev | line source |
---|---|
15 | 1 // This file (SystemStats.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. |
2 // | |
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. | |
4 | |
0 | 5 using System; |
6 using System.Collections.Generic; | |
7 | |
8 namespace IBBoard.WarFoundry.API.Objects | |
9 { | |
10 /// <summary> | |
10 | 11 /// SystemStats defines the available statistics/attributes that entity types can use (either a unit or an equipment item that has a stats line). Statistic/attribute values will be defined by a <see cref="Stats"/> object. |
0 | 12 /// </summary> |
13 public class SystemStats | |
14 { | |
67
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
15 private Dictionary<string, StatSlot> statsByName; |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
16 private List<StatSlot> stats; |
0 | 17 private string id; |
18 | |
67
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
19 public SystemStats(string statsID) |
0 | 20 { |
21 id = statsID; | |
67
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
22 statsByName = new Dictionary<string, StatSlot>(); |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
23 stats = new List<StatSlot>(); |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
24 } |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
25 |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
26 public void AddStatSlot(string slotName) |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
27 { |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
28 StatSlot slot = new StatSlot(slotName); |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
29 slot.SystemStats = this; |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
30 statsByName[slot.Name] = slot; |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
31 stats.Add(slot); |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
32 } |
0 | 33 |
34 public StatSlot[] StatSlots | |
35 { | |
36 get | |
37 { | |
67
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
38 return stats.ToArray(); |
0 | 39 } |
40 } | |
41 | |
67
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
42 public StatSlot this[string statName] |
0 | 43 { |
44 get | |
45 { | |
67
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
46 return DictionaryUtils.GetValue(statsByName, statName); |
0 | 47 } |
48 } | |
67
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
49 |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
50 public int GetStatSlotPosition(StatSlot slot) |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
51 { |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
52 return stats.IndexOf(slot); |
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
53 } |
0 | 54 |
55 public int SlotCount | |
56 { | |
57 get { return stats.Count; } | |
58 } | |
59 | |
60 public string ID | |
61 { | |
62 get { return id; } | |
63 } | |
64 } | |
65 } |