Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Objects/UnitType.cs @ 357:50d0d3b39a0b
Re #140: Add equality methods
* Add equality method for RequiresAtLeastNUnitsRequirement
* Update equality method on GameSystem and No More Than limit to use new helper class
* Add equality methods on Race and UnitType as a dependent of equality of requirements
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 26 Apr 2011 19:19:08 +0000 |
parents | 51cccccf3669 |
children | 1a70ca80ef41 |
comparison
equal
deleted
inserted
replaced
356:51cccccf3669 | 357:50d0d3b39a0b |
---|---|
43 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) | 43 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) |
44 { | 44 { |
45 race = parentRace; | 45 race = parentRace; |
46 } | 46 } |
47 | 47 |
48 public override bool Equals (object obj) | |
49 { | |
50 if (obj == null) | |
51 { | |
52 return false; | |
53 } | |
54 else if (!(obj is UnitType)) | |
55 { | |
56 return false; | |
57 } | |
58 else | |
59 { | |
60 UnitType other = (UnitType)obj; | |
61 | |
62 if (!ID.Equals(other.ID) || !Name.Equals(other.Name) || !Race.Equals(other.Race)) | |
63 { | |
64 return false; | |
65 } | |
66 else | |
67 { | |
68 return true; | |
69 } | |
70 } | |
71 } | |
72 | |
48 public GameSystem GameSystem | 73 public GameSystem GameSystem |
49 { | 74 { |
50 get { return Race.GameSystem; } | 75 get { return Race.GameSystem; } |
51 } | 76 } |
52 | 77 |