Fix: boh
This commit is contained in:
@@ -2,7 +2,7 @@ package it.polimi.ingsw.gc14;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LimitedList<String> extends ArrayList<String> {
|
||||
public class LimitedList<T> extends ArrayList<T> {
|
||||
private int limit;
|
||||
private final Runnable action;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class LimitedList<String> extends ArrayList<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(String element) {
|
||||
public boolean add(T element) {
|
||||
boolean result = super.add(element);
|
||||
if (size() >= limit) {
|
||||
action.run();
|
||||
@@ -20,7 +20,7 @@ public class LimitedList<String> extends ArrayList<String> {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setElement(int num) {
|
||||
public void setLimit(int num) {
|
||||
this.limit=num;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RMIServer implements IGameServer {
|
||||
{
|
||||
Game game= new Game(preferredInt);
|
||||
controller.setModel(game);
|
||||
playerList.setElement(preferredInt);
|
||||
playerList.setLimit(preferredInt);
|
||||
}
|
||||
playerList.add(username);
|
||||
clients.put(username, callback);
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ServerLauncher {
|
||||
GameController gameController;
|
||||
RMIServer serverRMI;
|
||||
TCPServer serverTCP;
|
||||
LimitedList players;
|
||||
static LimitedList<String> players;
|
||||
|
||||
|
||||
|
||||
@@ -59,8 +59,8 @@ public class ServerLauncher {
|
||||
|
||||
BlockingQueue<NetworkEvent> actionQueue = new LinkedBlockingQueue<>();
|
||||
GameController gameController = new GameController();
|
||||
RMIServer serverRMI = new RMIServer(gameController, 1099, actionQueue);
|
||||
TCPServer serverTCP = new TCPServer(gameController, 8080, actionQueue);
|
||||
RMIServer serverRMI = new RMIServer(gameController, 1099, actionQueue, players);
|
||||
TCPServer serverTCP = new TCPServer(gameController, 8080, actionQueue, players);
|
||||
|
||||
ServerLauncher launcher = new ServerLauncher(actionQueue, gameController, serverRMI, serverTCP);
|
||||
launcher.run();
|
||||
@@ -68,10 +68,7 @@ public class ServerLauncher {
|
||||
|
||||
public void run() throws InterruptedException, RemoteException {
|
||||
|
||||
// Aggiunge il primo player e imposta il numero di giocatori voluti
|
||||
Game model = new Game(players.getLimit());
|
||||
gameController.setModel(model);
|
||||
serverRMI.notifyAll(model);
|
||||
serverRMI.notifyAll(gameController.getModel());
|
||||
//serverTCP.broadcastUpdate(model);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user