annotate API/Objects/Requirement/UnitCountRequirementData.cs @ 397:5733e3b957cc Ticket341-DefaultArmySize

Re #341: Default army size of 0 * Set sensible defaults in GameSystem Also: * Setup .hgignore
author IBBoard <dev@ibboard.co.uk>
date Sun, 21 Aug 2011 20:42:23 +0100
parents 51cccccf3669
children 0922851f6125
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
356
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
1 // This file (UnitCountRequirementData.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
2 //
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
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.
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
4 using System;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
5 using IBBoard.WarFoundry.API.Objects;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
6
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
7 namespace IBBoard.WarFoundry.API.Objects.Requirement
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
8 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
9 public class UnitCountRequirementData
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
10 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
11 private UnitType unitType;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
12 private int count;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
13
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
14 public UnitCountRequirementData(UnitType unitType, int count)
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
15 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
16 this.unitType = unitType;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
17 this.count = count;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
18 }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
19
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
20 public UnitType UnitType
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
21 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
22 get { return unitType; }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
23 }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
24
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
25 public int Count
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
26 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
27 get { return count; }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
28 }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
29
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
30 public override bool Equals (object obj)
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
31 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
32 if (obj == null)
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
33 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
34 return false;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
35 }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
36 else if (!(obj is UnitCountRequirementData))
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
37 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
38 return false;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
39 }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
40 else
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
41 {
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
42 UnitCountRequirementData other = (UnitCountRequirementData)obj;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
43 return UnitType.Equals(other.UnitType) && Count == other.Count;
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
44 }
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46
356
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
47 public override int GetHashCode()
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 {
356
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
49 return UnitType.GetHashCode() + Count;
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 }
356
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
51 }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
52 }
51cccccf3669 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
53