Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate API/Objects/Requirement/UnitCountRequirementData.cs @ 437:0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
* Extend unit count requirement data to handle fixed numbers of units allowed per unit required
* Add initial stub of requirement using some copy-and-paste, but starting to avoid ticket:379
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 29 Nov 2011 20:55:21 +0000 |
parents | 51cccccf3669 |
children | 206a45fdfa9e |
rev | line source |
---|---|
356 | 1 // This file (UnitCountRequirementData.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard |
2 // | |
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. | |
4 using System; | |
5 using IBBoard.WarFoundry.API.Objects; | |
6 | |
7 namespace IBBoard.WarFoundry.API.Objects.Requirement | |
8 { | |
9 public class UnitCountRequirementData | |
10 { | |
11 private UnitType unitType; | |
12 private int count; | |
437
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
13 private int allows; |
356 | 14 |
437
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
15 public UnitCountRequirementData(UnitType unitType, int count) : this(unitType, count, WarFoundryCore.INFINITY) |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
16 { |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
17 //Do nothing special |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
18 } |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
19 |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
20 public UnitCountRequirementData(UnitType unitType, int count, int allows) |
356 | 21 { |
22 this.unitType = unitType; | |
23 this.count = count; | |
437
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
24 this.allows = allows; |
356 | 25 } |
26 | |
27 public UnitType UnitType | |
28 { | |
29 get { return unitType; } | |
30 } | |
31 | |
32 public int Count | |
33 { | |
34 get { return count; } | |
35 } | |
36 | |
437
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
37 public int AllowsCount |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
38 { |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
39 get { return allows; } |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
40 } |
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
41 |
356 | 42 public override bool Equals (object obj) |
43 { | |
44 if (obj == null) | |
45 { | |
46 return false; | |
47 } | |
48 else if (!(obj is UnitCountRequirementData)) | |
49 { | |
50 return false; | |
51 } | |
52 else | |
53 { | |
54 UnitCountRequirementData other = (UnitCountRequirementData)obj; | |
437
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
55 return UnitType.Equals(other.UnitType) && Count == other.Count && AllowsCount == other.AllowsCount; |
356 | 56 } |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 |
356 | 59 public override int GetHashCode() |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 { |
437
0922851f6125
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
356
diff
changeset
|
61 return UnitType.GetHashCode() + Count + AllowsCount; |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 } |
356 | 63 } |
64 } | |
65 |