fix: fixed equals in Lobby

This commit is contained in:
Yannik Bretschneider 2021-06-06 17:44:28 +02:00
parent 0c8dd3f1a8
commit e689248f9e

View File

@ -217,25 +217,25 @@ public class Lobby {
return activePlayer; return activePlayer;
} }
// Note: DO NOT ADD the connection to the equals and hashcode here, otherwise they recursively call each other
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Lobby lobby = (Lobby) o; Lobby lobby = (Lobby) o;
return badRequests == lobby.badRequests && Objects.equals(gameID, lobby.gameID) && Objects.equals(connection, lobby.connection) && Objects.equals(game, lobby.game) && Objects.equals(pipeline, lobby.pipeline) && Objects.equals(activePlayer, lobby.activePlayer) && Objects.equals(pauseSegment, lobby.pauseSegment) && Objects.equals(turnTimer, lobby.turnTimer); return badRequests == lobby.badRequests && Objects.equals(gameID, lobby.gameID) && Objects.equals(game, lobby.game) && Objects.equals(pipeline, lobby.pipeline) && Objects.equals(activePlayer, lobby.activePlayer) && Objects.equals(pauseSegment, lobby.pauseSegment) && Objects.equals(turnTimer, lobby.turnTimer);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(gameID, connection, game, pipeline, activePlayer, badRequests, pauseSegment, turnTimer); return Objects.hash(gameID, game, pipeline, activePlayer, badRequests, pauseSegment, turnTimer);
} }
@Override @Override
public String toString() { public String toString() {
return "Lobby{" + return "Lobby{" +
"gameID='" + gameID + '\'' + "gameID='" + gameID + '\'' +
", connection=" + connection +
", game=" + game + ", game=" + game +
", pipeline=" + pipeline + ", pipeline=" + pipeline +
", activePlayer=" + activePlayer + ", activePlayer=" + activePlayer +