Merge remote-tracking branch 'origin/Application' into Application
This commit is contained in:
commit
39c0d4e52f
@ -31,8 +31,9 @@ public class HumanNPC extends Human {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a msg to the ServerGameInfoHandler.humanNpcParser to decide what has to happen now, if the
|
||||
* npc hasn't been kicked off 8(should never happen to a human though)
|
||||
* Sends a msg to the ServerGameInfoHandler.humanNpcParser to decide what has to happen now, if
|
||||
* the npc hasn't been kicked off 8(should never happen to a human though)
|
||||
*
|
||||
* @param msg the message that is sent to this player.
|
||||
* @param game the game the HumanNPC lives on (in game.gameState.passengerTrain)
|
||||
*/
|
||||
@ -44,8 +45,9 @@ public class HumanNPC extends Human {
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently returns a random integer for voting, but only for passengers that haven't been
|
||||
* kicked off yet
|
||||
* Currently returns a random integer for voting, but only for passengers that haven't been kicked
|
||||
* off yet
|
||||
*
|
||||
* @param game the game this NPC lives on
|
||||
*/
|
||||
public void vote(Game game) {
|
||||
|
||||
@ -400,6 +400,8 @@ public class Client {
|
||||
case GuiParameters.newLobbyCreated:
|
||||
makeNewLobby(data);
|
||||
break;
|
||||
case GuiParameters.newPlayerOnServer:
|
||||
addNewPlayerToGui(data);
|
||||
default:
|
||||
notificationTextDisplay(data);
|
||||
//TODO(Sebi,Seraina): should the gameController be in the Application just like the ChatController?
|
||||
@ -412,17 +414,22 @@ public class Client {
|
||||
|
||||
}
|
||||
|
||||
private void addNewPlayerToGui(String data) {
|
||||
loungeSceneViewController.addClientToList(data);
|
||||
LOGGER.debug("addNewPlayerToGui() seems to have finished");
|
||||
}
|
||||
|
||||
private void makeNewLobby(String data) {
|
||||
String[] params = data.split(":");
|
||||
loungeSceneViewController.newLobby(params[0], params[1]);
|
||||
LOGGER.debug("makeNewLobby() seems to have finnished");
|
||||
LOGGER.debug("makeNewLobby() seems to have finished");
|
||||
|
||||
}
|
||||
|
||||
private void addPlayerToLobby(String data) {
|
||||
String[] params = data.split(":");
|
||||
loungeSceneViewController.addPlayerToLobby(params[0], params[1]);
|
||||
LOGGER.debug("addPlayerToLobby() seems to have finnished");
|
||||
LOGGER.debug("addPlayerToLobby() seems to have finished");
|
||||
}
|
||||
|
||||
private void updateLobbyMembers(String data) {
|
||||
|
||||
@ -28,6 +28,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class GameController implements Initializable {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(GameController.class);
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
@ -39,6 +40,7 @@ public class GameController implements Initializable{
|
||||
public GameController() {
|
||||
super();
|
||||
}
|
||||
|
||||
//TODO(Seraina, Sebi): Same issue as ChatController? do with setters?
|
||||
public GameController(ClientModel c, GameStateModel g) {
|
||||
client = c;
|
||||
@ -177,7 +179,8 @@ public class GameController implements Initializable{
|
||||
LOGGER.info("But why???");
|
||||
}
|
||||
client.getClient().sendMsgToServer(
|
||||
Protocol.sendMessageToAllClients + "$" + Protocol.printToGUI + "$" +GuiParameters.noiseHeardAtPosition + "$"
|
||||
Protocol.sendMessageToAllClients + "$" + Protocol.printToGUI + "$"
|
||||
+ GuiParameters.noiseHeardAtPosition + "$"
|
||||
+ client.getClient().getPosition()); //TODO: Test!!
|
||||
}
|
||||
|
||||
@ -191,6 +194,7 @@ public class GameController implements Initializable{
|
||||
|
||||
/**
|
||||
* Takes a given message and displays it in the notificationText Flow in the game Scene
|
||||
*
|
||||
* @param msg the message to be displayed
|
||||
*/
|
||||
public void addMessageToNotificationText(String msg) {
|
||||
@ -385,7 +389,8 @@ public class GameController implements Initializable{
|
||||
try {
|
||||
noiseImage2.setImage(loadBellImage());
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug(e.getMessage());;
|
||||
LOGGER.debug(e.getMessage());
|
||||
;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -9,6 +9,7 @@ public class ClientListItem {
|
||||
private final int id;
|
||||
|
||||
private static int uid = 0;
|
||||
|
||||
public ClientListItem(String name, int id) {
|
||||
this.name = new SimpleStringProperty(name);
|
||||
this.id = id;
|
||||
|
||||
@ -26,8 +26,7 @@ public class LobbyListItem {
|
||||
private final int MAX_CAPACITY = 6;
|
||||
private SimpleIntegerProperty noOfPlayersInLobby;
|
||||
|
||||
public LobbyListItem(SimpleStringProperty lobbyID,
|
||||
SimpleStringProperty adminName,
|
||||
public LobbyListItem(SimpleStringProperty lobbyID, SimpleStringProperty adminName,
|
||||
SimpleBooleanProperty ownedByClient, SimpleBooleanProperty isOpen,
|
||||
SimpleIntegerProperty noOfPlayersInLobby) {
|
||||
this.lobbyID = lobbyID;
|
||||
@ -66,8 +65,7 @@ public class LobbyListItem {
|
||||
return clientsInLobby;
|
||||
}
|
||||
|
||||
public void setClientsInLobby(
|
||||
ObservableList<SimpleStringProperty> clientsInLobby) {
|
||||
public void setClientsInLobby(ObservableList<SimpleStringProperty> clientsInLobby) {
|
||||
this.clientsInLobby = clientsInLobby;
|
||||
}
|
||||
|
||||
@ -113,14 +111,9 @@ public class LobbyListItem {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LobbyListItem{" +
|
||||
"lobbyID=" + lobbyID +
|
||||
", adminName=" + adminName +
|
||||
", clientsInLobby=" + clientsInLobby +
|
||||
", ownedByClient=" + ownedByClient +
|
||||
", isOpen=" + isOpen +
|
||||
", MAX_CAPACITY=" + MAX_CAPACITY +
|
||||
", noOfPlayersInLobby=" + noOfPlayersInLobby +
|
||||
'}';
|
||||
return "LobbyListItem{" + "lobbyID=" + lobbyID + ", adminName=" + adminName
|
||||
+ ", clientsInLobby=" + clientsInLobby + ", ownedByClient=" + ownedByClient + ", isOpen="
|
||||
+ isOpen + ", MAX_CAPACITY=" + MAX_CAPACITY + ", noOfPlayersInLobby=" + noOfPlayersInLobby
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,15 +339,6 @@ public class LoungeSceneViewController implements Initializable {
|
||||
});
|
||||
}
|
||||
|
||||
public void updateClientListView(ObservableList<ClientListItem> names) {
|
||||
ObservableList<ClientListItem> clientsLeft = ClientListView.getItems();
|
||||
clientsLeft.removeAll(names);
|
||||
this.ClientListView.setItems(names);
|
||||
for (ClientListItem gone : clientsLeft) {
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds players to a lobby
|
||||
* "NMEMB" {@link ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters}
|
||||
@ -439,6 +430,20 @@ public class LoungeSceneViewController implements Initializable {
|
||||
|
||||
}
|
||||
|
||||
public void removeClientFromList(String name){
|
||||
Iterator<ClientListItem> it = clients.iterator();
|
||||
while (it.hasNext()) {
|
||||
String uid = it.next().getName();
|
||||
if (uid.equals(name)) {
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
} }
|
||||
|
||||
public void removeClientFromLobby(String s){
|
||||
//todo
|
||||
}
|
||||
|
||||
public void newGame() {
|
||||
client.getClient().sendMsgToServer(Protocol.createNewLobby);
|
||||
}
|
||||
@ -457,17 +462,6 @@ public class LoungeSceneViewController implements Initializable {
|
||||
});
|
||||
}
|
||||
|
||||
public void removePlayer(String id) {
|
||||
Iterator<SimpleStringProperty> it = client.getAllClients().iterator();
|
||||
while (it.hasNext()) {
|
||||
String uid = it.next().getValue();
|
||||
if (uid.equals(id)) {
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to set the client model for this class
|
||||
*
|
||||
|
||||
@ -79,4 +79,10 @@ public class GuiParameters {
|
||||
* Indicates a player has joined the server. Form: {@code NPLOS$<playerName>}
|
||||
*/
|
||||
public static final String newPlayerOnServer = "NPLOS";
|
||||
|
||||
/**
|
||||
* Tells gui to remove a certain player from the list of clients based on user name. Form: {@code
|
||||
* RMVLST$<playerName>}
|
||||
*/
|
||||
public static final String removePlayerFromList = "RMVLST";
|
||||
}
|
||||
|
||||
@ -475,8 +475,9 @@ public class ClientHandler implements Runnable {
|
||||
public void createNewLobby() {
|
||||
if (Lobby.clientIsInLobby(this) == -1) {
|
||||
Lobby newGame = new Lobby(this);
|
||||
guiUpdateAll(Protocol.printToGUI + "$" + GuiParameters.newLobbyCreated + "$" + getLobby()
|
||||
.getLobbyID() + ":" + getClientUserName());
|
||||
guiUpdateAll(
|
||||
Protocol.printToGUI + "$" + GuiParameters.newLobbyCreated + "$" + getLobby().getLobbyID()
|
||||
+ ":" + getClientUserName());
|
||||
LOGGER.debug("Lobby: " + getLobby().getLobbyID() + ". In method createNewLobby()");
|
||||
} else {
|
||||
sendAnnouncementToClient("You are already in lobby nr. " + Lobby.clientIsInLobby(this));
|
||||
|
||||
@ -65,6 +65,7 @@ public class JServerProtocolParser {
|
||||
} catch (Exception e) {
|
||||
h.setUsernameOnLogin("U.N. Owen");
|
||||
}
|
||||
h.guiUpdateAll(Protocol.printToGUI+"$"+GuiParameters.newPlayerOnServer+"$"+h.getClientUserName());
|
||||
break;
|
||||
case Protocol.nameChange:
|
||||
h.changeUsername(msg.substring(6));
|
||||
|
||||
Reference in New Issue
Block a user