annotate api/Objects/EquipmentItem.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 3ea0ab04352b
children 2f3cafb69799
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
1 // This file (EquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
2 //
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
4
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
5 using System;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
6 using System.Xml;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
7
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
8 namespace IBBoard.WarFoundry.API.Objects
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
9 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
10 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
11 /// Summary description for EquipmentItem.
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
12 /// </summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
13 public class EquipmentItem : WarFoundryObject
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
14 {
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
15 private double cost;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
16 private string description;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 private ArmourType armourType;
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
18 private Race equipForRace;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
19
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
20 public EquipmentItem(string id, string name, Race race) : base(id, name)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 equipForRace = race;
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
23 description = "";
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
24 armourType = ArmourType.None;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
25 }
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
26
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
27 [Obsolete("Use the three argument constructor and the appropriate 'set' methods")]
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
28 public EquipmentItem(string id, string name, double itemCost, double minimum, double maximum, ArmourType itemArmourType, Race race) : this(id, name, race)
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
29 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
30 ItemArmourType = itemArmourType;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
31 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
32
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
33 public ArmourType ItemArmourType
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
34 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
35 get { return armourType; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
36 set { armourType = value; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
37 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
38
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
39 public double Cost
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
40 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
41 get { return cost; }
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
42 set
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
43 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
44 if (value >= 0)
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
45 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
46 cost = value;
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
47 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
48 }
54
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
49 }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
50
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
51 public string Description
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
52 {
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
53 get { return description; }
3a90f70dac73 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
54 set { description = (value == null ? "" : value); }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 public Race EquipmentForRace
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 get { return equipForRace; }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
60 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
61
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
62 public bool CanBeUsedWithItem(EquipmentItem item)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
63 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
64 return CanBeUsedWithArmourType(item.ItemArmourType);
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
65 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
66
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
67 public bool CanBeUsedWithArmourType(ArmourType otherItemType)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
68 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
69 return (this.ItemArmourType & otherItemType) == 0;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
70 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
71 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
72 }