Implemented server re-registration when a server closes / updates

- When a server is closed, it will disappear from the server list
- When a player joins a server, the number of spaces left will decrease
- Servers now disappear instead of duplicating
- Added tests for ServerDescription
- Added documentation for new classes

Tags: #story[1247]
This commit is contained in:
Michael Rausch
2017-09-01 16:05:47 +12:00
parent 0c5d661995
commit b346d5a706
10 changed files with 316 additions and 136 deletions
@@ -3,7 +3,6 @@ package seng302.gameServer;
public class ServerDescription {
private String address;
private Integer portNum;
private String serverName;
private String mapName;
private Integer spacesLeft;
@@ -36,4 +35,39 @@ public class ServerDescription {
public Integer spacesLeft() {
return spacesLeft;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!ServerDescription.class.isAssignableFrom(obj.getClass())) {
return false;
}
final ServerDescription other = (ServerDescription) obj;
if (!this.getAddress().equals(other.getAddress()) ) {
return false;
}
if (!this.portNumber().equals(other.portNumber())){
return false;
}
if (!this.getMapName().equals(other.getMapName())){
return false;
}
if (!this.getName().equals(other.getName())){
return false;
}
return true;
}
@Override
public int hashCode() {
return this.getName().hashCode() + this.getAddress().hashCode() +
this.portNumber().hashCode() + this.getMapName().hashCode();
}
}