Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Objects/SystemStats.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 |
comparison
equal
deleted
inserted
replaced
336:3631c1493c7f | 337:3c4a6403a88c |
---|---|
1 // This file (SystemStats.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 System.Collections.Generic; | |
7 | |
8 namespace IBBoard.WarFoundry.API.Objects | |
9 { | |
10 /// <summary> | |
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. | |
12 /// </summary> | |
13 public class SystemStats | |
14 { | |
15 private Dictionary<string, StatSlot> statsByName; | |
16 private List<StatSlot> stats; | |
17 private string id; | |
18 | |
19 public SystemStats(string statsID) | |
20 { | |
21 id = statsID; | |
22 statsByName = new Dictionary<string, StatSlot>(); | |
23 stats = new List<StatSlot>(); | |
24 } | |
25 | |
26 public void AddStatSlot(string slotName) | |
27 { | |
28 StatSlot slot = new StatSlot(slotName); | |
29 slot.SystemStats = this; | |
30 statsByName[slot.Name.ToLower()] = slot; | |
31 stats.Add(slot); | |
32 } | |
33 | |
34 public StatSlot[] StatSlots | |
35 { | |
36 get | |
37 { | |
38 return stats.ToArray(); | |
39 } | |
40 } | |
41 | |
42 public StatSlot this[string statName] | |
43 { | |
44 get | |
45 { | |
46 return DictionaryUtils.GetValue(statsByName, statName.ToLower()); | |
47 } | |
48 } | |
49 | |
50 public int GetStatSlotPosition(StatSlot slot) | |
51 { | |
52 return stats.IndexOf(slot); | |
53 } | |
54 | |
55 public void RemoveStatSlot(string name) | |
56 { | |
57 statsByName.Remove(name); | |
58 stats.Remove(this[name]); | |
59 } | |
60 | |
61 public int SlotCount | |
62 { | |
63 get { return stats.Count; } | |
64 } | |
65 | |
66 public string ID | |
67 { | |
68 get { return id; } | |
69 } | |
70 } | |
71 } |