annotate api/Objects/UnitType.cs @ 68:10d14a7051d5

Re #50 - Complete core loading of WarFoundry XML files * Start to restructure loading so that we can use pre-existing objects * Break unit loading in to methods Also: * Pad stats list with nulls because setting capacity doesn't let you set arbitrary indexes * Add GameSystem property to UnitType
author IBBoard <dev@ibboard.co.uk>
date Sat, 25 Apr 2009 19:18:11 +0000
parents e6200220ece3
children 91cf8efbea0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
1 // This file (UnitType.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
2 //
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
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.
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
4
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
5 using System;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.Collections.Generic;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.Xml;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.Logging;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API.Requirements;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 namespace IBBoard.WarFoundry.API.Objects
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 /// <summary>
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
14 /// A UnitType is a type for a <see cref=" Unit"/>, normally relating to an entry in an army list. The UnitType defines the name, cost, minimum and maximum limits of a unit, and the equipment units of the type can take.
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 /// </summary>
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public class UnitType : WarFoundryObject
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
18 private Category mainCat;
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
19 private Race race;
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
20 private int min, max, baseSize = 0;
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
21 private int minSize, maxSize;
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
22 private double baseUnitCost;
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
23 private double costPerTrooper;
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
24 private Stats stats;
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
25 private List<UnitRequirement> requirements = new List<UnitRequirement>();
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
26 private Dictionary<string, UnitEquipmentItem> equipment = new Dictionary<string, UnitEquipmentItem>();
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
27 private Dictionary<string, List<UnitEquipmentItem>> equipmentExclusionGroups = new Dictionary<string, List<UnitEquipmentItem>>();
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
28 private List<string> equipmentKeyOrder = new List<string>();
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
29 private Dictionary<string, Ability> requiredAbilities = new Dictionary<string, Ability>();
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
30 private Dictionary<string, Ability> optionalAbilities = new Dictionary<string, Ability>();
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
31 private List<String> notes = new List<string>();
66
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
32 private List<UnitType> containedTypes = new List<UnitType>();
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
33 private Dictionary<string, string> extraData = new Dictionary<string, string>();
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
34
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
35
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
36 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName)
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
37 {
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
38 race = parentRace;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
39 }
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
40
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
41 [Obsolete("Use three parameter constructor and setters")]
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
42 public UnitType(string id, string typeName, string mainCategoryID, string[] allCategoryIDs, int minNum, int maxNum, int minimumSize, int maximumSize, double unitCost, double trooperCost, Stats unitStats, UnitRequirement[] unitRequirements, Race parentRace) : this (id, typeName, parentRace)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 {
34
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
44 mainCat = race.GetCategory(mainCategoryID);
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
45 MinNumber = minNum;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
46 MaxNumber = maxNum;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
47 MinSize = minimumSize;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
48 MaxSize = maximumSize;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
49 BaseUnitCost = unitCost;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
50 CostPerTrooper = trooperCost;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
51 UnitStats = unitStats;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
52
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
53 foreach (UnitRequirement requirement in requirements)
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
54 {
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
55 AddRequirement(requirement);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
58
68
10d14a7051d5 Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
59 public GameSystem GameSystem
10d14a7051d5 Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
60 {
10d14a7051d5 Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
61 get { return Race.GameSystem; }
10d14a7051d5 Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
62 }
10d14a7051d5 Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
63
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
64 /// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
65 /// Gets the <see cref=" Race"/> that this unit belongs to.
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
66 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 public Race Race
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 get { return race; }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
71
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
72 /// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
73 /// Gets or sets the <see cref=" Category"/> that this unit type is a member of.
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
74 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 public virtual Category MainCategory
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 get
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
78 {
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 return mainCat;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
81 set
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
82 {
34
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
83 mainCat = value;
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
84 }
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
85 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
86
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
87 /// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
88 /// Gets or sets the minimum size of each unit of this type. Note: This should be set AFTER MaxSize, 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
89 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 public int MinSize
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 get { return minSize; }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
93 set
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
94 {
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
95 minSize = (value >= 0 ? value : 0);
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
96 CheckMinimumSize();
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
97 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
99
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
100 /// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
101 /// Gets or sets the maximum size of each unit of this type. Note: This should be set BEFORE MinSize, 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
102 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 public int MaxSize
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 get { return maxSize; }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
106 set
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
107 {
38
548cfc776f54 Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
108 maxSize = (value >= 0 ? value : WarFoundryCore.INFINITY);
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
109 CheckMinimumSize();
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
110 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
112
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
113 /// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
114 /// Gets or sets the minimum number of units of this type that must be taken in an army. Note: This should be set AFTER MaxNumber, 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
115 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 public int MinNumber
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 get { return min; }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
119 set
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 min = (value >= 0 ? value : 0);
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
122 CheckMinimumNumber();
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
123 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
125
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
126 /// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
127 /// Gets or sets the maximum number of units of this type that can be taken in an army. Note: This should be set BEFORE MinNumber, 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
128 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 public int MaxNumber
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 get { return max; }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
132 set
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
133 {
38
548cfc776f54 Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
134 max = (value >= 0 ? value : WarFoundryCore.INFINITY);
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
135 CheckMinimumNumber();
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
136 }
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
137 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
138
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
139 /// <summary>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
140 /// Makes sure that the minimum number isn't more than the maximum number, hence the warning on the properties
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
141 /// </summary>
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
142 private void CheckMinimumNumber()
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
143 {
38
548cfc776f54 Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
144 if (MinNumber > MaxNumber && MaxNumber!=WarFoundryCore.INFINITY)
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
145 {
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
146 MinNumber = MaxNumber;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
147 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum number greater than their maximum number.", Name, ID);
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
148 }
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
149 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
150
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
151 /// <summary>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
152 /// Makes sure that the minimum unit size isn't more than the maximum unit size, hence the warning on the properties
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
153 /// </summary>
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
154 private void CheckMinimumSize()
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
155 {
38
548cfc776f54 Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
156 if (MinSize > MaxSize && MaxSize!=WarFoundryCore.INFINITY)
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
157 {
34
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
158 MinSize = MaxSize;
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
159 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum size greater than their maximum size.", Name, ID);
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
160 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
163 //// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
164 /// Gets or sets the "base size" of a unit, which is the number of troopers the unit has in it for its "base cost". For a lot of units this value will be 0 as the cost is worked out based on the total number of members.
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
165 /// </value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
166 public int BaseSize
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
167 {
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
168 get { return baseSize; }
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
169 set { baseSize = (value >= 0 ? value : 0); }
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
170 }
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
171
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
172 /// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
173 /// The number of points that a "base unit" of <code>BaseSize</code> models costs. Additional models are charged at <code>CostPerTrooper</code> each.
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
174 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 public double BaseUnitCost
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 {
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
177 get { return baseUnitCost; }
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
178 set { baseUnitCost = (value >= 0 ? value : 0); }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
180
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
181 //// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
182 /// The cost of an individual trooper. This value is the cost for a basic trooper without weapons, which are added on top of the cost before calculating a unit cost.
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
183 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
184 public double CostPerTrooper
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 get { return costPerTrooper; }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
187 set { costPerTrooper = (value >= 0 ? value : 0); }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 protected override string DefaultName()
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
191 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 throw new InvalidOperationException("Unit type with id "+id+" did not have a name specified");
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
193 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
194
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
195 /// <value>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
196 /// The <see cref=" Stats"/> for the unit in a format that is valid for the game system.
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
197 /// </value>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
198 public Stats UnitStats
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
199 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
200 get
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
201 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 return stats;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203 }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
204 set
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
205 {
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
206 if (value!=null)
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
207 {
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
208 stats = value;
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
209 }
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
210 }
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
211 }
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
212
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
213 public void AddEquipmentItem(UnitEquipmentItem item)
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
214 {
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
215 equipment.Add(item.ID, item);
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
216 equipmentKeyOrder.Add(item.ID);
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
217 AddToMutexGroup(item);
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
218 }
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
219
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
220 private void AddToMutexGroup(UnitEquipmentItem item)
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
221 {
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
222 string mutexGroup = item.MutexGroup;
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
223
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
224 if (mutexGroup!="" && mutexGroup!=null)
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
225 {
66
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
226 List<UnitEquipmentItem> items = DictionaryUtils.GetValue(equipmentExclusionGroups, mutexGroup);
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
227
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
228 if (items == null)
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
229 {
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
230 items = new List<UnitEquipmentItem>();
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
231 equipmentExclusionGroups.Add(mutexGroup, items);
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
232 }
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
233
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
234 items.Add(item);
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
235 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
236 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
237
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
238 /// <summary>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
239 /// Gets a <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
240 /// </summary>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
241 /// <param name="id">
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
242 /// The ID of the UnitEquipmentItem to get
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
243 /// </param>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
244 /// <returns>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
245 /// The <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
246 /// </returns>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
247 public UnitEquipmentItem GetEquipmentItem(string id)
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
248 {
66
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
249 return DictionaryUtils.GetValue(equipment, id);
64
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
250 }
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
251
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
252 /// <summary>
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
253 /// Gets a <see cref=" UnitEquipmentItem"/> for the given <see cref=" EquipmentItem"/>, or <code>null</code> if the unit can't take that <code>EquipmentItem</code>
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
254 /// </summary>
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
255 /// <param name="item">
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
256 /// The <see cref="EquipmentItem"/> to get the <see cref=" UnitEquipmentItem"/>
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
257 /// </param>
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
258 /// <returns>
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
259 /// The <see cref="UnitEquipmentItem"/> that definies the UnitType's restrictions for taking the <see cref=" EquipmentItem"/>
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
260 /// </returns>
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
261 public UnitEquipmentItem GetEquipmentItem(EquipmentItem item)
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
262 {
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
263 return GetEquipmentItem(item.ID);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
264 }
46
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
265
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
266 /// <summary>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
267 /// Gets an array of all available <see cref="UnitEquipmentItem"/>s for this UnitType
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
268 /// </summary>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
269 /// <returns>
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
270 /// An array of all available <see cref="UnitEquipmentItem"/>s for this UnitType
a5855fcd75ab Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
271 /// </returns>
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
272 public UnitEquipmentItem[] GetEquipmentItems()
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
273 {
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
274 return DictionaryUtils.ToArray<string, UnitEquipmentItem>(equipment);
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
275 }
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
276
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
277 public UnitEquipmentItem[] GetEquipmentItemsByExclusionGroup(string group)
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
278 {
67
e6200220ece3 Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 66
diff changeset
279 List<UnitEquipmentItem> list = DictionaryUtils.GetValue(equipmentExclusionGroups, group);
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
280
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
281 if (list == null)
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
282 {
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
283 return new UnitEquipmentItem[0];
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
284 }
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
285 else
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
286 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
287 return list.ToArray();
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
288 }
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
289 }
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
290
64
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
291 public bool IsRatioLimitedEquipmentItem(EquipmentItem item)
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
292 {
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
293 UnitEquipmentItem equip = GetEquipmentItem(item);
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
294 return equip != null && equip.IsRatioLimit;
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
295 }
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
296
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
297 public bool IsAbsoluteLimitedEquipmentItem(EquipmentItem item)
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
298 {
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
299 UnitEquipmentItem equip = GetEquipmentItem(item);
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
300 return equip != null && !equip.IsRatioLimit;
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
301 }
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
302
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
303 public ICollection<Ability> GetRequiredAbilities()
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
304 {
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
305 return requiredAbilities.Values;
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
306 }
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
307
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
308 public ICollection<Ability> GetOptionalAbilities()
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
309 {
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
310 return optionalAbilities.Values;
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
311 }
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
312
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
313 public void AddAbility(Ability ability, bool isRequired)
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
314 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
315 string id = ability.ID;
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
316
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
317 if (!requiredAbilities.ContainsKey(id) && !optionalAbilities.ContainsKey(id))
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
318 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
319 if (isRequired)
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
320 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
321 requiredAbilities[id] = ability;
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
322 }
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
323 else
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
324 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
325 optionalAbilities[id] = ability;
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
326 }
56
9561ef46c6fb Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
327 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
328 }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
329
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
330 public void AddRequirement(UnitRequirement requirement)
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
331 {
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
332 requirements.Add(requirement);
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
333 }
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
334
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
335 public UnitRequirement[] Requirements
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
336 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
337 get { return requirements.ToArray(); }
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
338 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
339
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
340 public List<FailedUnitRequirement> CanAddToArmy(Army army)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
341 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
342 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
343
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
344 if (requirements!=null && requirements.Count > 0)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
345 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
346 foreach (UnitRequirement requirement in requirements)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
347 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
348 FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanAddToWarFoundryObject(army);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
349
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
350 if (failure!=null)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
351 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
352 failures.Add(failure);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
353 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
354 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
355 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
356
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
357 return failures;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
358 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
359
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
360 public List<FailedUnitRequirement> CanRemoveFromArmy(Army army)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
361 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
362 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
363
12
ac232763858b Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
364 if (requirements!=null && requirements.Count > 0)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
365 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
366 foreach (UnitRequirement requirement in requirements)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
367 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
368 FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanRemoveFromWarFoundryObject(army);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
369
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
370 if (failure!=null)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
371 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
372 failures.Add(failure);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
373 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
374 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
375 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
376
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
377 return failures;
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
378 }
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
379
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
380 public string[] Notes
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
381 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
382 get { return notes.ToArray(); }
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
383 }
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
384
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
385 public void AddNote(string note)
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
386 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
387 notes.Add(note);
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
388 }
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
389
61
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
390 public bool CanContainUnit(Unit unit)
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
391 {
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
392 return CanContainUnitType(unit.UnitType);
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
393 }
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
394
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
395 public bool CanContainUnitType(UnitType unitType)
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
396 {
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
397 return containedTypes.Contains(unitType);
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
398 }
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
399
57
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
400 public UnitType[] ContainedUnitTypes
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
401 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
402 get { return containedTypes.ToArray(); }
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
403 }
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
404
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
405 public void AddContainedUnitType(UnitType containedType)
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
406 {
e0ce5578e7c2 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
407 containedTypes.Add(containedType);
66
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
408 }
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
409
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
410 public void AddExtraData(string id, string data)
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
411 {
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
412 extraData[id] = data;
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
413 }
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
414
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
415 public string GetExtraData(string id)
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
416 {
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
417 return DictionaryUtils.GetValue(extraData, id);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
418 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
419 }
66
d100ca4bd0c1 Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
420 }