Mercurial > repos > IBBoard.WarFoundry.API
annotate api/Objects/CompositeEquipmentItem.cs @ 101:f7b9423c2a5a
Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
This revision will be broken for the WinForms UI, but as MonoDevelop/eSVN don't have a way of committing multiple projects in one go it can't be helped (Eclipse's Team Sync view could handle it)
Fixes #122: Make usage of percentage or ratio common
* All usage of ratio amounts for equipment items should now assume percentage
* Properly calculate number taken for ratio selection (divide by 0 now we're using percentages)
Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
* Added extra commands that differentiate between ratio and absolute amounts
Fixes #120: Numeric limit equipment items show large percentages
* Now made formatting treat ratios as percentages (don't multiply by 100)
* Move string formatting to UnitEquipmentItem...Selection classes
* Add method to Unit to say whether an equipment item is a numeric or ratio amount
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 13 Aug 2009 21:09:20 +0000 |
parents | 2094bd0ba652 |
children | 2f3cafb69799 |
rev | line source |
---|---|
62
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (CompositeEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 // |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System; |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using System.Collections.Generic; |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 namespace IBBoard.WarFoundry.API.Objects |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 { |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 /// <summary> |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 /// A special <see cref=" EquipmentItem"/> that is made up of a number of other <code>EquipmentItem</code>s |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 /// </summary> |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 public class CompositeEquipmentItem : EquipmentItem |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 private List<EquipmentItem> compositeItems; |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 public CompositeEquipmentItem(string id, string name, Race race) : base(id, name, race) |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 { |
63
a920b1bcb408
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
20 compositeItems = new List<EquipmentItem>(); |
62
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 } |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 public void AddItem(EquipmentItem item) |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 { |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 compositeItems.Add(item); |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 Cost+= item.Cost; |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 } |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 public void RemoveItem(EquipmentItem item) |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 { |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 compositeItems.Remove(item); |
64
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
63
diff
changeset
|
32 Cost-= item.Cost; |
62
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 } |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 public EquipmentItem[] Items |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 { |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 get { return compositeItems.ToArray(); } |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 } |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 } |
e8735def0db5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 } |