annotate api/Objects/UnitEquipmentItem.cs @ 161:81abc04b3dbe

Re #192: Improve "clean coding" practice * Move some calculation methods for equipment out of the encapsulation objects
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Oct 2009 12:00:16 +0000
parents 6ff68daab5dc
children 91f7b8da0b53
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 (UnitEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 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: 79
diff changeset
5 using System;
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 157
diff changeset
6 using IBBoard.Lang;
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 157
diff changeset
7 using IBBoard.WarFoundry.API.Util;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
8
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
10 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
11 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
12 /// Summary description for UnitEquipmentItem.
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
13 /// </summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
14 public class UnitEquipmentItem : WarFoundryObject
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
15 {
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
16 private EquipmentItem item;
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
17 private bool required;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
18 private bool roundUp;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
19 private int minNum;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
20 private int maxNum;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
21 private double minPercentage;
79
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
22 private double maxPercentage;
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
23 private double costMultiplier;
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
24 private RoundType roundType;
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
25 private string[] mutexGroups;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
26 private UnitType unitType;
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
27
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
28 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) : this(equipmentItem, equipmentFor, new string[0])
138
c11c0da01bbc Fixes #147: "Replace Weapon" button doesn't always enable (regression)
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
29 {
c11c0da01bbc Fixes #147: "Replace Weapon" button doesn't always enable (regression)
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
30 //Do nothing extra
c11c0da01bbc Fixes #147: "Replace Weapon" button doesn't always enable (regression)
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
31 }
c11c0da01bbc Fixes #147: "Replace Weapon" button doesn't always enable (regression)
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
32
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
33 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups)
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
34 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
35 item = equipmentItem;
92
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
36 unitType = equipmentFor;
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
37 this.mutexGroups = mutexGroups;
92
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
38 unitType.AddEquipmentItem(this);
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
39 }
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
40
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
41 public override string Name
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
42 {
92
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
43 get
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
44 {
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
45 return item.Name;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
46 }
92
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
47 set
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
48 {
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
49 base.Name = value;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
50 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
51 }
92
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
52
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
53 public override string ID {
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
54 get
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
55 {
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
56 return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID;
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
57 }
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
58 set
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
59 {
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
60 base.ID = value;
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
61 }
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
62 }
729d9e54162c Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
63
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
64
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
65 public string EquipmentItemID
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
66 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
67 get { return item.ID; }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
68 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
69
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
70 public double Cost
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
71 {
79
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
72 get
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
73 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
74 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
75 }
79
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
76 }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
77
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
78 public double CostMultiplier
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
79 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
80 get { return costMultiplier; }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
81 set
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
82 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
83 costMultiplier = value;
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
84 }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
85 }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
86
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
87 public RoundType CostRoundType
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
88 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
89 get { return roundType; }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
90 set
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
91 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
92 roundType = value;
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
93 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
94 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
95
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
96 public bool IsRequired
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
97 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
98 get { return required; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
99 set { required = value; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
100 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
101
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
102 public bool RoundNumberUp
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
103 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
104 get { return roundUp; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
105 set { roundUp = value; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
106 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
107
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
108 [Obsolete("Use MutexGroups instead for greater flexibility")]
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
109 public string MutexGroup
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
110 {
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
111 get { return (mutexGroups.Length == 0 ? "" : mutexGroups[0]); }
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
112 }
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
113
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
114 public String[] MutexGroups
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
115 {
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
116 get { return (string[]) mutexGroups.Clone(); }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
117 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
118
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
119 public UnitType EquipmentForUnit
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
120 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
121 get { return unitType; }
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
122 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
123
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
124 public bool IsRatioLimit
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
125 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
126 get { return minPercentage!=100 || maxPercentage!=100; }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
127 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
128
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
129 public int MinNumber
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
130 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
131 get { return minNum; }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
132 set
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
133 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
134 if (value >=0 || value == WarFoundryCore.INFINITY)
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
135 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
136 minNum = value;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
137 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
138 //TODO: Check Min<Max
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
139 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
140 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
141
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
142 public int MaxNumber
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
143 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
144 get { return maxNum; }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
145 set
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
146 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
147 if (value >=0 || value == WarFoundryCore.INFINITY)
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
148 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
149 maxNum = value;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
150 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
151 //TODO: Check Min<Max
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
152 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
153 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
154
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
155 public double MinPercentage
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
156 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
157 get { return minPercentage; }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
158 set
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
159 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
160 if (value >=0 && value <= 100)
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
161 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
162 minPercentage = value;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
163 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
164 //TODO: Check Min<Max
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
165 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
166 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
167
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
168 public double MaxPercentage
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
169 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
170 get { return maxPercentage; }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
171 set
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
172 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
173 if (value >=0 && value <= 100)
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
174 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
175 maxPercentage = value;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
176 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
177 //TODO: Check Min<Max
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
178 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
179 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
180
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
181 public EquipmentItem EquipmentItem
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
182 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
183 get { return item; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
184 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
185
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
186 public override string ToString()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
187 {
157
6ff68daab5dc Fixes #188: Add equipment window doesn't feature cost accurately
IBBoard <dev@ibboard.co.uk>
parents: 154
diff changeset
188 return EquipmentItem.Name + " (" + Cost + "pts each)";
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
189 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
190
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
191 public bool HasAlternatives()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
192 {
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
193 if (MutexGroups.Length == 0)
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
194 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
195 return false;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
196 }
85
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
197 else if (EquipmentForUnit == null)
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
198 {
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
199 return false;
46ad6f478203 Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
200 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
201 else
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
202 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
203 //If the number of items in the MutEx group is greater than one then it must be this item plus another
152
0c0e14f03785 Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
204 return EquipmentForUnit.GetEquipmentItemsByExclusionGroups(MutexGroups).Length > 1;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
205 }
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
206 }
79
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
207
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
208 public ArmourType ItemArmourType
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
209 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
210 get { return EquipmentItem.ItemArmourType; }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
211 }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
212
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
213 public string Description
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
214 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
215 get { return EquipmentItem.Description; }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
216 }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
217
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
218 public Race EquipmentForRace
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
219 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
220 get { return EquipmentItem.EquipmentForRace; }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
221 }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
222
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
223 public bool CanBeUsedWithItem(EquipmentItem item)
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
224 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
225 return EquipmentItem.CanBeUsedWithItem(item);
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
226 }
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
227
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
228 public bool CanBeUsedWithArmourType(ArmourType otherItemType)
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
229 {
284ebe05158c Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
230 return EquipmentItem.CanBeUsedWithArmourType(otherItemType);
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
231 }
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
232
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 157
diff changeset
233 [Obsolete("Use UnitEquipmentUtil method instead")]
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
234 public bool IsMutuallyExclusive(UnitEquipmentItem item)
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 157
diff changeset
235 {
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 157
diff changeset
236 return UnitEquipmentUtil.ItemsAreMutuallyExclusive(this, item);
154
4a02c07278e7 Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents: 152
diff changeset
237 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
238 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
239 }