annotate api/Objects/SystemStats.cs @ 295:f8f441f2fcfe

Re #323: WarFoundry.API - SystemStats cannot remove stat Update SystemStats Implement RemoveStatSlot
author Tsudico
date Sat, 18 Dec 2010 20:53:52 +0000
parents 8c6f55d289b0
children ed5e6d92ecd9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
1 // This file (SystemStats.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
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.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
4
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
6 using System.Collections.Generic;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
7
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
8 namespace IBBoard.WarFoundry.API.Objects
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
9 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
10 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
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.
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
12 /// </summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
13 public class SystemStats
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
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;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
17 private string id;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
18
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
19 public SystemStats(string statsID)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 {
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
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>();
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
23 stats = new List<StatSlot>();
67
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;
181
8c6f55d289b0 Fixes #200: Stats names should be case-insensitive
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
30 statsByName[slot.Name.ToLower()] = slot;
67
e6200220ece3 Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
31 stats.Add(slot);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
32 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
33
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
34 public StatSlot[] StatSlots
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
35 {
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 get
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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();
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
39 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 get
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 {
181
8c6f55d289b0 Fixes #200: Stats names should be case-insensitive
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
46 return DictionaryUtils.GetValue(statsByName, statName.ToLower());
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
54
295
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
55 public void RemoveStatSlot(string name)
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
56 {
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
57 statsByName.Remove(name);
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
58 StatSlot slot = new StatSlot(name);
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
59 slot.SystemStats = this;
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
60 stats.Remove(slot);
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
61 }
f8f441f2fcfe Re #323: WarFoundry.API - SystemStats cannot remove stat
Tsudico
parents: 181
diff changeset
62
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
63 public int SlotCount
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
64 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
65 get { return stats.Count; }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 public string ID
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 get { return id; }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
71 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
72 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
73 }