Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Objects/Category.cs @ 46:a5855fcd75ab
Re #11 - Document classes and methods
* Document methods in UnitType and Category classes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 23 Mar 2009 20:57:07 +0000 |
parents | 548cfc776f54 |
children | 3ea0ab04352b |
rev | line source |
---|---|
15 | 1 // This file (Category.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.Xml; | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
7 using IBBoard.Logging; |
0 | 8 |
9 namespace IBBoard.WarFoundry.API.Objects | |
10 { | |
11 /// <summary> | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
12 /// A Category is a definition at the <see cref=" GameSystem"/> or <see cref=" Race"/> level of a group that <see cref=" UnitType"/>s belong to. Each category has a name and a min/max limit on points or percentage of a total army cost that units in the category can total. |
0 | 13 /// </summary> |
14 public class Category : WarFoundryObject | |
15 { | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
16 private int minPts = 0; |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
17 private int maxPts = WarFoundryCore.INFINITY; |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
18 private int minPc = 0; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
19 private int maxPc = 100; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
20 |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
21 |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
22 public Category(string id, string name) : base(id, name) |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
23 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
24 } |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
25 |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
26 [Obsolete("Use the two argument constructor and the appropriate 'set' methods")] |
0 | 27 public Category(string id, string name, int minPoints, int maxPoints, int minPercent, int maxPercent, int minChoices, int maxChoices, int baseValue, int incrementValue, int incrementAmount) : base(id, name) |
28 { | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
29 MinimumPoints = minPoints; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
30 MaximumPoints = maxPoints; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
31 MinimumPercentage = minPercent; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
32 MaximumPercentage = maxPercent; |
0 | 33 } |
34 | |
35 protected override string DefaultName() | |
36 { | |
37 return ""; | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
38 } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
39 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
40 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
41 /// Gets or sets the minimum number of points that the units of this category can cost. Note: This should be set AFTER MaximumPoints, otherwise an unintended default value may be set for the minimum |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
42 /// </value> |
0 | 43 public int MinimumPoints |
44 { | |
45 get { return minPts; } | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
46 set |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
47 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
48 minPts = (value >= 0 ? value : 0); |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
49 CheckMinimumPoints(); |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
50 } |
0 | 51 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
52 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
53 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
54 /// Gets or sets the maximum number of points that the units of this category can cost. Note: This should be set BEFORE MinimumPoints, otherwise an unintended default value may be set for the minimum |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
55 /// </value> |
0 | 56 public int MaximumPoints |
57 { | |
58 get { return maxPts; } | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
59 set |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
60 { |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
61 maxPts = (value >= 0 ? value : WarFoundryCore.INFINITY); |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
62 CheckMinimumPoints(); |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
63 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
64 } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
65 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
66 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
67 /// Makes sure that the minimum points value isn't more than the maximum points value, hence the warning on the properties |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
68 /// </summary> |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
69 private void CheckMinimumPoints() |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
70 { |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
71 if (MinimumPoints > MaximumPoints && MaximumPoints!=WarFoundryCore.INFINITY) |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
72 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
73 MinimumPoints = MaximumPoints; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
74 LogNotifier.WarnFormat(GetType(), "Category {0} ({1}) had a minimum points limit greater than its maximum points limit.", Name, ID); |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
75 } |
0 | 76 } |
77 | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
78 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
79 /// Gets or sets the minimum percentage of the total army points value that the units of this category can cost. Note: This should be set AFTER MaximumPercentage, otherwise an unintended default value may be set for the minimum |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
80 /// </value> |
0 | 81 public int MinimumPercentage |
82 { | |
83 get { return minPc; } | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
84 set |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
85 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
86 minPc = (value >= 0 ? value : 0); |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
87 CheckMinimumPercentage(); |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
88 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
89 } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
90 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
91 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
92 /// Gets or sets the maximum percentage of the total army points value that the units of this category can cost. Note: This should be set BEFORE MinimumPercentage, otherwise an unintended default value may be set for the minimum |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
93 /// </value> |
0 | 94 public int MaximumPercentage |
95 { | |
96 get { return maxPc; } | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
97 set |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
98 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
99 if (value < 0) |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
100 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
101 maxPc = 0; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
102 } |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
103 else if (value > 100) |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
104 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
105 maxPc = 100; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
106 } |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
107 else |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
108 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
109 maxPc = value; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
110 } |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
111 |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
112 CheckMinimumPercentage(); |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
113 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
114 } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
115 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
116 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
117 /// Makes sure that the minimum percentage value isn't more than the maximum points value, hence the warning on the properties |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
118 /// </summary> |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
119 private void CheckMinimumPercentage() |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
120 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
121 if (MinimumPercentage > MaximumPercentage) |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
122 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
123 MinimumPercentage = MaximumPercentage; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
124 LogNotifier.WarnFormat(GetType(), "Category {0} ({1}) had a minimum percentage limit greater than its maximum percentage limit.", Name, ID); |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
125 } |
0 | 126 } |
127 } | |
128 } |