annotate api/Objects/Unit.cs @ 197:ec1cfe3ef94e

* Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots) no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Fri, 30 Oct 2009 21:02:48 +0000
parents 36adabb1c3ea
children 4d7ff70bb109
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: 101
diff changeset
1 // This file (Unit.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 2007, 2008, IBBoard.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
2 //
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 101
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: 0
diff changeset
4
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
5 using System;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
6 using System.Collections.Generic;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
7 using System.Text;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using System.Xml;
164
91f7b8da0b53 * Line-ending fix
IBBoard <dev@ibboard.co.uk>
parents: 162
diff changeset
9 using IBBoard.Lang;
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 180
diff changeset
10 using IBBoard.Limits;
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 158
diff changeset
11 using IBBoard.WarFoundry.API.Util;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
12
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
13 namespace IBBoard.WarFoundry.API.Objects
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
14 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
15 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
16 /// Summary description for UnitInstance.
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
17 /// </summary>
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
18 public class Unit : WarFoundryObject, ICostedWarFoundryObject
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
19 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
20 private UnitType type;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
21 private int size;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
22 private Unit parentUnit;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
23 private double points;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
24 private ArmyCategory cat;
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
25 private Dictionary<UnitEquipmentItem, AbstractUnitEquipmentItemSelection> equipment = new Dictionary<UnitEquipmentItem, AbstractUnitEquipmentItemSelection>();
178
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
26 private Dictionary<string, List<AbstractUnitEquipmentItemSelection>> equipmentSlots = new Dictionary<string, List<AbstractUnitEquipmentItemSelection>>();
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
27 private List<Unit> containedUnits = new List<Unit>();
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
28 public event DoubleValChangedDelegate PointsValueChanged;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
29 public event IntValChangedDelegate UnitSizeChanged;
85
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
30 public event DoubleValChangedDelegate UnitEquipmentAmountChanged;
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
31
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
32 public Unit(UnitType unitType, ArmyCategory parentArmyCat) : this(unitType, unitType.MinSize, parentArmyCat) { }
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
33
123
52e8c3cdde10 Re #127: Unit creation always assigns default equipment
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
34 public Unit(UnitType unitType, int startSize, ArmyCategory parentArmyCat) : this("", "", startSize, unitType, parentArmyCat)
52e8c3cdde10 Re #127: Unit creation always assigns default equipment
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
35 {
52e8c3cdde10 Re #127: Unit creation always assigns default equipment
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
36 SetInitialEquipment();
52e8c3cdde10 Re #127: Unit creation always assigns default equipment
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
37 }
52e8c3cdde10 Re #127: Unit creation always assigns default equipment
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
38
52e8c3cdde10 Re #127: Unit creation always assigns default equipment
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
39 public Unit(string id, string name, int startSize, UnitType unitType, ArmyCategory parentArmyCat) : base(id, name)
85
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
40 {
83
89cc29b4c012 Re #90: Stop new units showing up twice
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
41 Category = parentArmyCat;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
42 type = unitType;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
43 Size = startSize;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
44 CalcCost();
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
45 UnitEquipmentAmountChanged+= new DoubleValChangedDelegate(UnitEquipmentAmountChangedHandler);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
46 UnitSizeChanged+= new IntValChangedDelegate(UnitSizeChangedHandler);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
47 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
48
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
49 private void UnitEquipmentAmountChangedHandler(WarFoundryObject obj, double oldVal, double newVal)
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
50 {
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
51 CalcCost();
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
52 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
53
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
54 private void UnitSizeChangedHandler(WarFoundryObject obj, int oldVal, int newVal)
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
55 {
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
56 CalcCost();
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
57
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
58 if (HasDefaultName())
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
59 {
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
60 OnNameChanged("", Name);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
61 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
62 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
63
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
64 protected override string DefaultName()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
65 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
66 if (type != null)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
67 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
68 if (size == 1)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
69 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
70 return type.Name;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
71 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
72 else
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
73 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
74 return String.Format(Translation.GetTranslation("defaultUnitName"), size, type.Name);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
75 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
76 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
77 else
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
78 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
79 return "Unknown Unit";
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
80 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
81 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
83 private void SetInitialEquipment()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
84 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
85 foreach (UnitEquipmentItem unitEquip in UnitType.GetEquipmentItems())
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
86 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
87 if (unitEquip.IsRequired)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
88 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
89 if (CanEquipWithItem(unitEquip))
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
90 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 180
diff changeset
91 AbstractLimit minLimit = unitEquip.MinLimit;
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 180
diff changeset
92
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 180
diff changeset
93 if (minLimit is IPercentageLimit)
151
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 149
diff changeset
94 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 180
diff changeset
95 SetEquipmentRatio(unitEquip, ((IPercentageLimit)minLimit).Percentage);
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
96 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
97 else
151
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 149
diff changeset
98 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 180
diff changeset
99 SetEquipmentAmount(unitEquip, minLimit.GetLimit(this.Size));
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
100 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
101 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
102 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
103 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
104 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
105
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
106 private void CalcCost()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
107 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
108 double oldpoints = points;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
109 points = type.CostPerTrooper * AdditionalTroopers + type.BaseUnitCost;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
110
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
111 foreach (AbstractUnitEquipmentItemSelection equipSelection in equipment.Values)
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
112 {
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
113 points += equipSelection.TotalCost;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
114 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
115
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
116 if (oldpoints!=points)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
117 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
118 OnPointsValueChanged(oldpoints, points);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
119 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 public int AdditionalTroopers
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 get { return Math.Max(Size - type.BaseSize, 0); }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
125 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
126
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
127 public int Size
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
128 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
129 get { return size; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
130 set
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
131 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
132 if (value!=size)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
133 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
134 int oldValue = size;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
135 size = (value>0 ? value : 1);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
136 OnUnitSizeChanged(oldValue, size);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
137 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
138 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
139 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
140
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
141 public UnitType UnitType
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 {
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
143 get { return type; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
144 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
145
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
146 public Army Army
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
147 {
83
89cc29b4c012 Re #90: Stop new units showing up twice
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
148 get { return (Category == null ? null : Category.ParentArmy); }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
149 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
150
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
151 public Race Race
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
152 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
153 get { return UnitType.Race; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
154 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
155
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
156 public ArmyCategory Category
85
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
157 {
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
158 get
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
159 {
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 83
diff changeset
160 return cat;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
161 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
162 set { cat = value; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
163 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
164
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
165 [Obsolete("Use Points instead")]
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
166 public double PointsValue
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
167 {
143
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
168 get { return Points; }
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
169 }
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
170
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
171 public double Points
7f13ffcb8765 Re #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
172 {
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
173 get
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
174 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
175 if (points == 0)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
176 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
177 CalcCost();
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
178 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
179
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
180 return points;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
181 }
61
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
182 }
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
183
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
184 public Unit[] ContainedUnits
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
185 {
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
186 get { return containedUnits.ToArray(); }
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
187 }
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
188
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
189 public void AddContainedUnit(Unit unit)
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
190 {
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
191 if (UnitType.CanContainUnit(unit))
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
192 {
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
193 if (!containedUnits.Contains(unit))
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
194 {
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
195 containedUnits.Add(unit);
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
196 }
65
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
197
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
198 unit.ParentUnit = this;
61
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
199 }
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
200 else
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
201 {
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
202 throw new InvalidContainershipException(this, unit);
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
203 }
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
204 }
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
205
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
206 public void RemoveContainedUnit(Unit unit)
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
207 {
3c77722a02b5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
208 containedUnits.Remove(unit);
65
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
209 }
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
210
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
211 public Unit ParentUnit
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
212 {
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
213 get { return parentUnit; }
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
214 set
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
215 {
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
216 if (!(parentUnit == value || (parentUnit != null && parentUnit.Equals(value))))
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
217 {
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
218 parentUnit = value;
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
219
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
220 if (value!=null)
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
221 {
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
222 value.AddContainedUnit(this);
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
223 }
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
224 }
aa2d05a9c635 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
225 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
226 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
227
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 158
diff changeset
228 [Obsolete("Use UnitEquipmentUtil.GetAllowedEquipmentItems(Unit) instead")]
158
eb9a6d91a6db Fixes #190: Mutex groups aren't honoured when adding equipment
IBBoard <dev@ibboard.co.uk>
parents: 154
diff changeset
229 public UnitEquipmentItem[] GetAllowedAdditionalEquipment()
164
91f7b8da0b53 * Line-ending fix
IBBoard <dev@ibboard.co.uk>
parents: 162
diff changeset
230 {
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 158
diff changeset
231 return UnitEquipmentUtil.GetAllowedEquipmentItems(this);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
232 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
233
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
234 public UnitEquipmentItem[] GetEquipment()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
235 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
236 return DictionaryUtils.ToKeyArray(equipment);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
237 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
238
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
239 public EquipmentItem[] GetRequiredEquipment()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
240 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
241 List<EquipmentItem> list = new List<EquipmentItem>();
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
242
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
243 foreach(UnitEquipmentItem item in GetEquipment())
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
244 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
245 if (item.IsRequired)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
246 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
247 list.Add(item.EquipmentItem);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
248 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
249 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
250
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
251 return list.ToArray();
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
252 }
64
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
253
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
254 public double GetEquipmentAmount(UnitEquipmentItem item)
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
255 {
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
256 double amount = 0;
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
257 AbstractUnitEquipmentItemSelection selection = DictionaryUtils.GetValue(equipment, item);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
258
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
259 if (selection != null)
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
260 {
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
261 amount = selection.AmountTaken;
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
262 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
263
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
264 return amount;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
265 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
266
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
267 public double GetEquipmentAmount(string equipID)
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
268 {
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
269 return GetEquipmentAmount(UnitType.GetEquipmentItem(equipID));
64
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
270 }
101
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
271
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
272 public bool GetEquipmentAmountIsRatio(UnitEquipmentItem item)
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
273 {
134
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
274 return IsEquipmentAmountRatio(GetEquipmentSelection(item));
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
275 }
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
276
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
277 private AbstractUnitEquipmentItemSelection GetEquipmentSelection(UnitEquipmentItem item)
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
278 {
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
279 return DictionaryUtils.GetValue(equipment, item);
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
280 }
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
281
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
282 private bool IsEquipmentAmountRatio(AbstractUnitEquipmentItemSelection selection)
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
283 {
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
284 return (selection is UnitEquipmentRatioSelection);
101
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
285 }
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
286
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
287 public bool GetEquipmentAmountIsRatio(string itemID)
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
288 {
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
289 return GetEquipmentAmountIsRatio(UnitType.GetEquipmentItem(itemID));
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
290 }
134
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
291
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
292 public string GetEquipmentAmountString(string equipID)
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
293 {
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
294 return GetEquipmentAmountString(UnitType.GetEquipmentItem(equipID));
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
295 }
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
296
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
297 public string GetEquipmentAmountString(UnitEquipmentItem item)
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
298 {
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
299 String amountString = "";
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
300 AbstractUnitEquipmentItemSelection selection = GetEquipmentSelection(item);
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
301
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
302 if (IsEquipmentAmountRatio(selection))
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
303 {
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
304 amountString = UnitEquipmentRatioSelection.GetEquipmentAmountString(GetEquipmentAmount(item));
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
305 }
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
306 else
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
307 {
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
308 amountString = UnitEquipmentNumericSelection.GetEquipmentAmountString(GetEquipmentAmount(item));
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
309 }
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
310
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
311 return amountString;
57f7b80757ea Re #68: Export army to another format
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
312 }
64
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
313
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
314 public void SetEquipmentAmount(UnitEquipmentItem equip, int amount)
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
315 {
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
316 if (amount <1 && amount != WarFoundryCore.INFINITY)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
317 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
318 amount = 0;
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
319 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
320
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
321 if (amount == 0)
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
322 {
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
323 RemoveEquipmentItem(equip);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
324 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
325 else
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
326 {
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
327 AbstractUnitEquipmentItemSelection currSelection = DictionaryUtils.GetValue(equipment, equip);
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
328 double oldAmount = (currSelection == null ? 0 : currSelection.AmountTaken);
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
329
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
330 if (amount != oldAmount)
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
331 {
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
332 if (oldAmount == 0)
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
333 {
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
334 AddEquipmentAmount(equip, amount);
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
335 }
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
336 else if (currSelection is UnitEquipmentNumericSelection)
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
337 {
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
338 //A UnitEquipmentItem shouldn't change its IsRatio value, so assume we already have the right sub-type
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
339 currSelection.AmountTaken = amount;
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
340 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
341 else
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
342 {
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
343 equipment.Remove(equip);
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
344 AddEquipmentAmount(equip, amount);
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
345 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
346
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
347 OnUnitEquipmentAmountChanged(equip, oldAmount, amount);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
348 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
349 }
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
350 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
351
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
352 private void AddEquipmentAmount(UnitEquipmentItem equip, int amount)
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
353 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 180
diff changeset
354 AbstractUnitEquipmentItemSelection newItem = new UnitEquipmentNumericSelection(this, equip, amount);
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
355 equipment[equip] = newItem;
178
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
356 List<AbstractUnitEquipmentItemSelection> selections = DictionaryUtils.GetValue(equipmentSlots, equip.SlotName);
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
357
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
358 if (selections == null)
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
359 {
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
360 selections = new List<AbstractUnitEquipmentItemSelection>();
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
361 equipmentSlots[equip.SlotName] = selections;
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
362 }
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
363
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
364 selections.Add(newItem);
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
365 }
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
366
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
367 public void SetEquipmentRatio(UnitEquipmentItem equip, double ratio)
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
368 {
80
aa66dd18cdae Closes #81 - Resolve Unit Equipment problems in WinForms GUI
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
369 if (!equip.IsRatioLimit)
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
370 {
64
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
371 throw new InvalidOperationException("Equipment with ID "+equip.ID+" for unit of type "+UnitType.ID+" has an absolute limit, not a ratio limit");
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
372 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
373
101
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
374 if (ratio > 100)
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
375 {
101
f7b9423c2a5a Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
376 ratio = 100;
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
377 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
378 else if (ratio < 0)
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
379 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
380 ratio = 0;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
381 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
382
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
383 if (ratio == 0)
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
384 {
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
385 RemoveEquipmentItem(equip);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
386 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
387 else
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
388 {
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
389 AbstractUnitEquipmentItemSelection currSelection = DictionaryUtils.GetValue(equipment, equip);
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
390 double oldRatio = (currSelection == null ? 0 : currSelection.AmountTaken);
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
391
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
392 if (ratio != oldRatio)
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
393 {
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
394 if (oldRatio == 0)
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
395 {
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
396 AddEquipmentRatio(equip, ratio);
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
397 }
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
398 else if (currSelection is UnitEquipmentRatioSelection)
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
399 {
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
400 currSelection.AmountTaken = ratio;
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
401 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
402 else
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
403 {
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
404 equipment.Remove(equip);
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
405 AddEquipmentRatio(equip, ratio);
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
406 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
407
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
408 OnUnitEquipmentAmountChanged(equip, oldRatio, ratio);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
409 }
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
410 }
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
411 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 38
diff changeset
412
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
413 private void AddEquipmentRatio(UnitEquipmentItem equip, double ratio)
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
414 {
178
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
415 UnitEquipmentRatioSelection newItem = new UnitEquipmentRatioSelection (this, equip, ratio);
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
416 equipment[equip] = newItem;
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
417 List<AbstractUnitEquipmentItemSelection> selections = DictionaryUtils.GetValue(equipmentSlots, equip.SlotName);
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
418
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
419 if (selections == null)
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
420 {
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
421 selections = new List<AbstractUnitEquipmentItemSelection>();
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
422 equipmentSlots[equip.SlotName] = selections;
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
423 }
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
424
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
425 selections.Add(newItem);
98
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
426 }
4dd1c41c95b4 Fixes #119: Handle changing of equipment between absolute and ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
427
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
428 private void RemoveEquipmentItem(UnitEquipmentItem equip)
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
429 {
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
430 double oldAmount = GetEquipmentAmount(equip);
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
431
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
432 if (oldAmount != 0)
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
433 {
178
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
434 AbstractUnitEquipmentItemSelection selection = DictionaryUtils.GetValue (equipment, equip);
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
435 equipment.Remove(equip);
178
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
436 List<AbstractUnitEquipmentItemSelection> slotSelections = DictionaryUtils.GetValue (equipmentSlots, equip.SlotName);
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
437 slotSelections.Remove(selection);
96
ced5a18d9f52 Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 90
diff changeset
438 OnUnitEquipmentAmountChanged(equip, oldAmount, 0);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
439 }
64
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
440 }
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
441
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
442 public bool CanEquipWithItem(UnitEquipmentItem item)
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
443 {
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
444 string[] mutexes = item.MutexGroups;
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
445 bool canEquip = false;
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
446
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
447 if (mutexes.Length == 0)
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
448 {
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
449 canEquip = true;
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
450 }
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
451 else
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
452 {
162
624422e91a1c Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 161
diff changeset
453 canEquip = UnitEquipmentUtil.GetBlockingEquipmentItems(this, item).Count == 0;
64
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
454 }
2094bd0ba652 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
455
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 151
diff changeset
456 return canEquip;
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
457 }
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
458
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 158
diff changeset
459 [Obsolete("Use UnitEquipmentUtil.GetBlockingEquipmentItems(Unit, UnitEquipmentItem) instead")]
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
460 public List<UnitEquipmentItem> GetBlockingEquipmentItems(UnitEquipmentItem item)
164
91f7b8da0b53 * Line-ending fix
IBBoard <dev@ibboard.co.uk>
parents: 162
diff changeset
461 {
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 158
diff changeset
462 return UnitEquipmentUtil.GetBlockingEquipmentItems(this, item);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
463 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
464
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
465 public bool CanEquipWithItem(string equipID)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
466 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
467 return CanEquipWithItem(UnitType.GetEquipmentItem(equipID));
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
468 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
469
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
470 private void OnPointsValueChanged(double oldValue, double newValue)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
471 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
472 if (PointsValueChanged!=null)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
473 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
474 PointsValueChanged(this, oldValue, newValue);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
475 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
476 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
477
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
478 private void OnUnitSizeChanged(int oldValue, int newValue)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
479 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
480 if (UnitSizeChanged!=null)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
481 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
482 UnitSizeChanged(this, oldValue, newValue);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
483 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
484 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
485
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
486 private void OnUnitEquipmentAmountChanged(UnitEquipmentItem equip, double oldValue, double newValue)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
487 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
488 if (UnitEquipmentAmountChanged!=null)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
489 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
490 UnitEquipmentAmountChanged(equip, oldValue, newValue);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
491 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
492 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
493
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
494 public Stat[] UnitStatsArray
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
495 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
496 get { return UnitType.UnitStatsArray; }
81
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
497 }
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
498
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
499 public Stat[] UnitStatsArrayWithName
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
500 {
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
501 get { return UnitType.UnitStatsArrayWithName; }
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
502 }
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
503
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
504 public string GetStatValue(string statName)
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
505 {
032b174fc17a Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
506 return UnitType.GetStatValue(statName);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
507 }
178
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
508
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
509 public int GetEquipmentAmountInSlot (string slotName)
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
510 {
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
511 int amount = 0;
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
512
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
513 List<AbstractUnitEquipmentItemSelection> selections = DictionaryUtils.GetValue(equipmentSlots, slotName);
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
514
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
515 if (selections != null)
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
516 {
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
517 amount = GetSelectionTotal(selections);
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
518 }
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
519
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
520 return amount;
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
521 }
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
522
197
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
523 /// <summary>
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
524 /// Gets the total amount of items taken for the item's slot, excluding the provided item
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
525 /// </summary>
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
526 /// <param name="item">the item to exclude from the count</param>
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
527 /// <returns>the total number of items</returns>
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
528 public int GetEquipmentAmountInSlotWithoutItem(UnitEquipmentItem item)
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
529 {
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
530 int amount = 0;
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
531
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
532 List<AbstractUnitEquipmentItemSelection> selections = DictionaryUtils.GetValue(equipmentSlots, item.SlotName);
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
533
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
534 if (selections != null)
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
535 {
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
536 RemoveSelectionFromList(item, selections);
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
537 amount = GetSelectionTotal(selections);
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
538 }
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
539
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
540 return amount;
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
541 }
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
542
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
543 private void RemoveSelectionFromList(UnitEquipmentItem item, List<AbstractUnitEquipmentItemSelection> selections)
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
544 {
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
545 AbstractUnitEquipmentItemSelection selection = GetEquipmentSelection(item);
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
546
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
547 if (selection != null)
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
548 {
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
549 selections.Remove(selection);
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
550 }
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
551 }
ec1cfe3ef94e * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots)
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
552
178
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
553 private int GetSelectionTotal (List<AbstractUnitEquipmentItemSelection> selections)
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
554 {
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
555 int amount = 0;
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
556
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
557 foreach (AbstractUnitEquipmentItemSelection selection in selections)
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
558 {
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
559 amount+= selection.NumberTaken;
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
560 }
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
561
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
562 return amount;
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
563 }
ca2cd24f6872 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 164
diff changeset
564
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
565 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 81
diff changeset
566 }