mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user