no list of who is in lobby yet but at least functionally one is in a lobby and can play a game
This commit is contained in:
parent
a4a12fc9d2
commit
d6f28a63e8
@ -18,7 +18,7 @@ public class LobbyListItem {
|
|||||||
|
|
||||||
private final SimpleStringProperty lobbyID;
|
private final SimpleStringProperty lobbyID;
|
||||||
private final SimpleStringProperty adminName;
|
private final SimpleStringProperty adminName;
|
||||||
private ObservableList<SimpleStringProperty> clientsInLobby;
|
private ObservableList<ClientListItem> clientsInLobby;
|
||||||
|
|
||||||
private SimpleBooleanProperty ownedByClient;
|
private SimpleBooleanProperty ownedByClient;
|
||||||
private SimpleBooleanProperty isOpen;
|
private SimpleBooleanProperty isOpen;
|
||||||
@ -62,11 +62,11 @@ public class LobbyListItem {
|
|||||||
this.adminName.set(adminName);
|
this.adminName.set(adminName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<SimpleStringProperty> getClientsInLobby() {
|
public ObservableList<ClientListItem> getClientsInLobby() {
|
||||||
return clientsInLobby;
|
return clientsInLobby;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientsInLobby(ObservableList<SimpleStringProperty> clientsInLobby) {
|
public void setClientsInLobby(ObservableList<ClientListItem> clientsInLobby) {
|
||||||
this.clientsInLobby = clientsInLobby;
|
this.clientsInLobby = clientsInLobby;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +110,7 @@ public class LobbyListItem {
|
|||||||
this.noOfPlayersInLobby.set(noOfPlayersInLobby);
|
this.noOfPlayersInLobby.set(noOfPlayersInLobby);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "LobbyListItem{" + "lobbyID=" + lobbyID + ", adminName=" + adminName
|
return "LobbyListItem{" + "lobbyID=" + lobbyID + ", adminName=" + adminName
|
||||||
|
|||||||
@ -90,10 +90,12 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
|
|
||||||
private ObservableMap<String, ObservableList<String>> lobbyToMemberssMap;
|
private ObservableMap<String, ObservableList<String>> lobbyToMemberssMap;
|
||||||
private HashMap<String, String> clientToLobbyMap;
|
private HashMap<String, String> clientToLobbyMap;
|
||||||
|
private HashMap<String, LobbyListItem> lobbyIDtoLobbyMop;
|
||||||
|
|
||||||
public LoungeSceneViewController() {
|
public LoungeSceneViewController() {
|
||||||
super();
|
super();
|
||||||
lobbyToMemberssMap = FXCollections.observableHashMap();
|
lobbyToMemberssMap = FXCollections.observableHashMap();
|
||||||
|
lobbyIDtoLobbyMop = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChatApp(ChatApp chatApp) {
|
public void setChatApp(ChatApp chatApp) {
|
||||||
@ -282,7 +284,7 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
if (item.isOwnedByClient()) {
|
if (item.isOwnedByClient()) {
|
||||||
startGame();
|
startGame();
|
||||||
} else {
|
} else {
|
||||||
joinGame(item.lobbyIDProperty().getName());
|
joinGame(item.lobbyIDProperty().getValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
startOrJoin.setText(item.isOwnedByClient() ? "Start" : "Join");
|
startOrJoin.setText(item.isOwnedByClient() ? "Start" : "Join");
|
||||||
@ -354,8 +356,15 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
Platform.runLater(new Runnable() {
|
Platform.runLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ObservableList<String> members = lobbyToMemberssMap.get(lobbyID);
|
Iterator<ClientListItem> itr = clients.iterator();
|
||||||
members.add(player);
|
while(itr.hasNext()){
|
||||||
|
ClientListItem cl = itr.next();
|
||||||
|
if(cl.getName().equals(player)){
|
||||||
|
LobbyListItem li = lobbyIDtoLobbyMop.get(lobbyID);
|
||||||
|
li.getClientsInLobby().add(cl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -383,6 +392,7 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
}
|
}
|
||||||
LobbyListItem item = new LobbyListItem(id, admin, new SimpleBooleanProperty(ownedByClient),
|
LobbyListItem item = new LobbyListItem(id, admin, new SimpleBooleanProperty(ownedByClient),
|
||||||
new SimpleBooleanProperty(true), new SimpleIntegerProperty(0));
|
new SimpleBooleanProperty(true), new SimpleIntegerProperty(0));
|
||||||
|
lobbyIDtoLobbyMop.put(lobbyID,item);
|
||||||
LOGGER.debug("In newLobby()2 LobbyListView" + LobbyListView);
|
LOGGER.debug("In newLobby()2 LobbyListView" + LobbyListView);
|
||||||
Platform.runLater(new Runnable() {
|
Platform.runLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user