Commit c26a8a9f authored by Prieur Maxime's avatar Prieur Maxime 🎵

Fix bug

parent 8ff70ead
......@@ -64,6 +64,7 @@ public class Board implements IRender {
try{
_running = new RunningIMPL();
_serverGame.addRunningGame(_running);
_serverGame.setServerReset();
_pseudo.add(new Message(serverGame.getPlayerID(0), 0, 0, 1, Color.white, 14));
_pseudo.add(new Message(serverGame.getPlayerID(1), 0, 0, 1, Color.white, 14));
} catch (RemoteException e){
......@@ -142,7 +143,6 @@ public class Board implements IRender {
_mobs.clear();
_bombs.clear();
_messages.clear();
try {
_level = new FileLevel("data/Levels/Level" + level + ".txt", this);
_entities = new Entity[_level.getHeight() * _level.getWidth()];
......
......@@ -22,4 +22,5 @@ public interface ServerGame extends Remote{
boolean getRunningState() throws RemoteException;
void endRunningState() throws RemoteException;
void addRunningGame(Running state)throws RemoteException;
void setServerReset() throws RemoteException;
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ public class ServerGameImpl extends UnicastRemoteObject implements ServerGame {
private int[] playerBomb = new int[2];
private Boolean runningState = false;
private Thread controlThread;
private Boolean serverIsReset = true;
protected ServerGameImpl() throws RemoteException {
this.clientGames = new ArrayList<ClientGame>();
this.runningGames = new ArrayList<Running>();
......@@ -68,7 +68,7 @@ public class ServerGameImpl extends UnicastRemoteObject implements ServerGame {
public void startGame() throws RemoteException {
this.gameRunning = true;
this.controlThread = new Thread(new RunningTimeThread(this, 10000));
this.controlThread = new Thread(new RunningTimeThread(this, 210000));
this.controlThread.start();
}
......@@ -121,14 +121,18 @@ public class ServerGameImpl extends UnicastRemoteObject implements ServerGame {
}
public synchronized void resetServer() throws RemoteException{
this.runningState = false;
this.clientGames.clear();
this.gameRunning = false;
this.playerBomb[0] = 0;
this.playerBomb[1] = 0;
this.playerOnePos = new PlayerPosition(0,0,0);
this.playerTwoPos = new PlayerPosition(0,0,0);
//this.runningGames.clear();
if (!serverIsReset){
runningGames.get(0).setState(false);
runningGames.get(1).setState(false);
this.runningGames.clear();
this.clientGames.clear();
this.gameRunning = false;
this.playerBomb[0] = 0;
this.playerBomb[1] = 0;
this.playerOnePos = new PlayerPosition(0,0,0);
this.playerTwoPos = new PlayerPosition(0,0,0);
serverIsReset = true;
}
}
public synchronized String getPlayerID(int playerNum) throws RemoteException{
......@@ -145,10 +149,14 @@ public class ServerGameImpl extends UnicastRemoteObject implements ServerGame {
runningGames.get(i++).setState(false);
}
//this.runningState = false;
//this.controlThread.interrupt();
this.controlThread.interrupt();
}
public synchronized void addRunningGame(Running state) throws RemoteException{
this.runningGames.add(state);
}
public synchronized void setServerReset() throws RemoteException{
this.serverIsReset = false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment