merge the new developmentbranch into the test branch #39
@@ -216,12 +216,14 @@ public void connectionAdded(Server server, HostedConnection hostedConnection) {
|
|||||||
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyDenyMessage());
|
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyDenyMessage());
|
||||||
hostedConnection.close("");
|
hostedConnection.close("");
|
||||||
} else {
|
} else {
|
||||||
if (this.myServer.getConnections().size() == 1) {
|
if (hostedConnection.getAddress().contains("127.0.0.1") && this.logic.getGame().getHost() == -1) {
|
||||||
this.logic.getGame().setHost(hostedConnection.getId());
|
this.logic.getGame().setHost(hostedConnection.getId());
|
||||||
}
|
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage(hostedConnection.getId()));
|
||||||
|
} else {
|
||||||
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage());
|
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionRemoved(Server server, HostedConnection hostedConnection) {
|
public void connectionRemoved(Server server, HostedConnection hostedConnection) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class Game {
|
|||||||
private Die die;
|
private Die die;
|
||||||
|
|
||||||
// The host of this game
|
// The host of this game
|
||||||
private int host;
|
private int host = -1;
|
||||||
|
|
||||||
// The color of the active player.
|
// The color of the active player.
|
||||||
private Color activeColor;
|
private Color activeColor;
|
||||||
@@ -200,6 +200,15 @@ public Piece getPieceThroughUUID(UUID pieceId) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be used to check if this client is the host for the game.
|
||||||
|
*
|
||||||
|
* @return true or false.
|
||||||
|
*/
|
||||||
|
public boolean isHost() {
|
||||||
|
return this.host != -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the dice modifier.
|
* This method returns the dice modifier.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7,13 +7,39 @@
|
|||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class LobbyAcceptMessage extends ServerMessage {
|
public class LobbyAcceptMessage extends ServerMessage {
|
||||||
|
/**
|
||||||
|
* Create LobbyAcceptMessage attributes.
|
||||||
|
*/
|
||||||
|
private final int host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new LobbyAccept instance.
|
* Constructs a new LobbyAccept instance.
|
||||||
*/
|
*/
|
||||||
public LobbyAcceptMessage() {
|
public LobbyAcceptMessage() {
|
||||||
super();
|
super();
|
||||||
|
this.host = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param host as the id of the host as an Integer.
|
||||||
|
*/
|
||||||
|
public LobbyAcceptMessage(int host) {
|
||||||
|
super();
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be used return host attribute of LobbyAcceptMessage class.
|
||||||
|
*
|
||||||
|
* @return host as an Integer.
|
||||||
|
*/
|
||||||
|
public int getHost() {
|
||||||
|
return this.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts a visitor to process this message.
|
* Accepts a visitor to process this message.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user