refactor: removed callbacks and generated equals and hashcode for Lobby and LobbyConnection
This commit is contained in:
parent
d8a031f379
commit
07d440bfac
@ -216,4 +216,32 @@ public class Lobby {
|
|||||||
public Participant getActivePlayer() {
|
public Participant getActivePlayer() {
|
||||||
return activePlayer;
|
return activePlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(gameID, connection, game, pipeline, activePlayer, badRequests, pauseSegment, turnTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Lobby{" +
|
||||||
|
"gameID='" + gameID + '\'' +
|
||||||
|
", connection=" + connection +
|
||||||
|
", game=" + game +
|
||||||
|
", pipeline=" + pipeline +
|
||||||
|
", activePlayer=" + activePlayer +
|
||||||
|
", badRequests=" + badRequests +
|
||||||
|
", pauseSegment=" + pauseSegment +
|
||||||
|
", turnTimer=" + turnTimer +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,17 +34,10 @@ public class LobbyConnection implements Runnable {
|
|||||||
private final HashSet<Participant> spectators;
|
private final HashSet<Participant> spectators;
|
||||||
private final BlockingQueue<Tuple<Participant, BasicMessage>> incomingMessages;
|
private final BlockingQueue<Tuple<Participant, BasicMessage>> incomingMessages;
|
||||||
|
|
||||||
/**
|
|
||||||
* A callback executed to send a message, originating from the
|
|
||||||
* {@link uulm.teamname.marvelous.server.netconnector.UserManager}
|
|
||||||
*/
|
|
||||||
private final BiConsumer<Participant, BasicMessage> sendMessageCallback;
|
|
||||||
|
|
||||||
// TODO: FIX THIS JAVADOC
|
// TODO: FIX THIS JAVADOC
|
||||||
/** Creates a new LobbyConnection */
|
/** Creates a new LobbyConnection */
|
||||||
public LobbyConnection(String gameID, BiConsumer<Participant, BasicMessage> sendMessageCallback) {
|
public LobbyConnection(String gameID) {
|
||||||
this.gameID = gameID;
|
this.gameID = gameID;
|
||||||
this.sendMessageCallback = sendMessageCallback;
|
|
||||||
this.spectators = new HashSet<>(10);
|
this.spectators = new HashSet<>(10);
|
||||||
this.incomingMessages = new LinkedBlockingQueue<>();
|
this.incomingMessages = new LinkedBlockingQueue<>();
|
||||||
this.characterSelection = false;
|
this.characterSelection = false;
|
||||||
@ -325,18 +318,17 @@ public class LobbyConnection implements Runnable {
|
|||||||
// TODO: implement this
|
// TODO: implement this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@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;
|
||||||
LobbyConnection that = (LobbyConnection) o;
|
LobbyConnection that = (LobbyConnection) o;
|
||||||
return characterSelection == that.characterSelection && inGame == that.inGame && Objects.equals(lobby, that.lobby) && Objects.equals(gameID, that.gameID) && Objects.equals(player1, that.player1) && Objects.equals(player2, that.player2) && Objects.equals(spectators, that.spectators) && Objects.equals(incomingMessages, that.incomingMessages) && Objects.equals(sendMessageCallback, that.sendMessageCallback);
|
return characterSelection == that.characterSelection && inGame == that.inGame && Objects.equals(lobby, that.lobby) && Objects.equals(gameID, that.gameID) && Objects.equals(player1, that.player1) && Objects.equals(player2, that.player2) && Objects.equals(spectators, that.spectators) && Objects.equals(incomingMessages, that.incomingMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(lobby, gameID, player1, player2, characterSelection, inGame, spectators, incomingMessages, sendMessageCallback);
|
return Objects.hash(lobby, gameID, player1, player2, characterSelection, inGame, spectators, incomingMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -350,7 +342,6 @@ public class LobbyConnection implements Runnable {
|
|||||||
", inGame=" + inGame +
|
", inGame=" + inGame +
|
||||||
", spectators=" + spectators +
|
", spectators=" + spectators +
|
||||||
", incomingMessages=" + incomingMessages +
|
", incomingMessages=" + incomingMessages +
|
||||||
", sendMessageCallback=" + sendMessageCallback +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user