annotate api/Objects/SystemStats.cs @ 296:ed5e6d92ecd9

Re #323: WarFoundry.API - SystemStats cannot remove stat Remove code didn't fully remove stat, this has been fixed and tested
author Tsudico
date Sat, 18 Dec 2010 22:34:32 +0000
parents f8f441f2fcfe
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
296
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
1 // This file (SystemStats.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
2 //
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
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.
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
4
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
5 using System;
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
6 using System.Collections.Generic;
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
7
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
8 namespace IBBoard.WarFoundry.API.Objects
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
9 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
10 /// <summary>
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
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.
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
12 /// </summary>
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
13 public class SystemStats
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
14 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
15 private Dictionary<string, StatSlot> statsByName;
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
16 private List<StatSlot> stats;
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
17 private string id;
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
18
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
19 public SystemStats(string statsID)
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
20 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
21 id = statsID;
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
22 statsByName = new Dictionary<string, StatSlot>();
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
23 stats = new List<StatSlot>();
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
24 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
25
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
26 public void AddStatSlot(string slotName)
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
27 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
28 StatSlot slot = new StatSlot(slotName);
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
29 slot.SystemStats = this;
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
30 statsByName[slot.Name.ToLower()] = slot;
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
31 stats.Add(slot);
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
32 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
33
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
34 public StatSlot[] StatSlots
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
35 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
36 get
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
37 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
38 return stats.ToArray();
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
39 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
40 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
41
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
42 public StatSlot this[string statName]
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
43 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
44 get
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
45 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
46 return DictionaryUtils.GetValue(statsByName, statName.ToLower());
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
47 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
48 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
49
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
50 public int GetStatSlotPosition(StatSlot slot)
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
51 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
52 return stats.IndexOf(slot);
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
53 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
54
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
55 public void RemoveStatSlot(string name)
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
56 {
295
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
57 statsByName.Remove(name);
296
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
58 stats.Remove(this[name]);
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
59 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
60
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
61 public int SlotCount
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
62 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
63 get { return stats.Count; }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
64 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
65
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
66 public string ID
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
67 {
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
68 get { return id; }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
69 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
70 }
ed5e6d92ecd9 Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 295
diff changeset
71 }