Fix: ServerRMI interface bug
This commit is contained in:
@@ -5,6 +5,7 @@ import it.polimi.ingsw.gc14.Network.IClient;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
|
||||
import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -77,7 +78,11 @@ public class ClientController {
|
||||
}
|
||||
else
|
||||
{
|
||||
client.drawUpperTribeCard(playerUsername, pos);
|
||||
try {
|
||||
client.drawUpperTribeCard(playerUsername, pos);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +97,11 @@ public class ClientController {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.drawLowerTribeCard(playerUsername,pos);
|
||||
try {
|
||||
client.drawLowerTribeCard(playerUsername, pos);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +114,13 @@ public class ClientController {
|
||||
public void drawUpperBuildingCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.drawUpperBuildingCard(playerUsername,pos);
|
||||
else {
|
||||
try {
|
||||
client.drawUpperBuildingCard(playerUsername,pos);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -120,8 +134,13 @@ public class ClientController {
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.drawLowerBuildingCard(playerUsername,pos);
|
||||
else {
|
||||
try {
|
||||
client.drawLowerBuildingCard(playerUsername,pos);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,8 +152,13 @@ public class ClientController {
|
||||
public void skipUpper(String playerUsername) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.skipUpper(playerUsername);
|
||||
else {
|
||||
try {
|
||||
client.skipUpper(playerUsername);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,8 +170,13 @@ public class ClientController {
|
||||
public void skipLower(String playerUsername) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.skipLower(playerUsername);
|
||||
else {
|
||||
try {
|
||||
client.skipLower(playerUsername);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,8 +189,13 @@ public class ClientController {
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.pickOptionalTribeCard(playerUsername,pos);
|
||||
else {
|
||||
try {
|
||||
client.pickOptionalTribeCard(playerUsername,pos);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,8 +208,13 @@ public class ClientController {
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.pickOptionalBuildingCard(playerUsername,pos);
|
||||
else {
|
||||
try {
|
||||
client.pickOptionalBuildingCard(playerUsername,pos);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,8 +226,13 @@ public class ClientController {
|
||||
public void noOptionalCard(String playerUsername) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.noOptionalCard(playerUsername);
|
||||
else {
|
||||
try {
|
||||
client.noOptionalCard(playerUsername);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,8 +244,13 @@ public class ClientController {
|
||||
public void slotChoice(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
client.slotChoice(playerUsername,pos);
|
||||
else {
|
||||
try {
|
||||
client.slotChoice(playerUsername,pos);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,26 +8,26 @@ import java.util.Objects;
|
||||
public interface IClient {
|
||||
public boolean connect(String username,int preferredInt);
|
||||
|
||||
public void drawUpperTribeCard(String playerUsername, int pos) ;
|
||||
public void drawUpperTribeCard(String playerUsername, int pos) throws RemoteException;
|
||||
|
||||
public void drawLowerTribeCard(String playerUsername,int pos) ;
|
||||
public void drawLowerTribeCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
public void drawUpperBuildingCard(String playerUsername,int pos);
|
||||
public void drawUpperBuildingCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) ;
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
public void skipUpper(String playerUsername) ;
|
||||
public void skipUpper(String playerUsername) throws RemoteException;
|
||||
|
||||
public void skipLower(String playerUsername) ;
|
||||
public void skipLower(String playerUsername) throws RemoteException;
|
||||
|
||||
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) ;
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos);
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
|
||||
public void noOptionalCard(String playerUsername) ;
|
||||
public void noOptionalCard(String playerUsername) throws RemoteException;
|
||||
|
||||
public void slotChoice(String playerUsername,int pos) ;
|
||||
public void slotChoice(String playerUsername,int pos) throws RemoteException;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RMIClient implements IClient {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void drawUpperTribeCard(String playerUsername, int pos) {
|
||||
public void drawUpperTribeCard(String playerUsername, int pos) throws RemoteException {
|
||||
stub.drawUpperTribeCard(playerUsername,pos);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class RMIClient implements IClient {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void drawLowerTribeCard(String playerUsername,int pos) {
|
||||
public void drawLowerTribeCard(String playerUsername,int pos) throws RemoteException {
|
||||
stub.drawLowerTribeCard(playerUsername,pos);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class RMIClient implements IClient {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void drawUpperBuildingCard(String playerUsername,int pos) {
|
||||
public void drawUpperBuildingCard(String playerUsername,int pos) throws RemoteException {
|
||||
stub.drawUpperBuildingCard(playerUsername,pos);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class RMIClient implements IClient {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) {
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) throws RemoteException {
|
||||
stub.drawLowerBuildingCard(playerUsername,pos);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class RMIClient implements IClient {
|
||||
* This action is available only when the upper list is empty or the player cannot draw any card.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void skipUpper(String playerUsername) {
|
||||
public void skipUpper(String playerUsername) throws RemoteException {
|
||||
stub.skipUpper(playerUsername);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class RMIClient implements IClient {
|
||||
* This action is available only when the lower list is empty or the player cannot draw any card.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void skipLower(String playerUsername) {
|
||||
public void skipLower(String playerUsername) throws RemoteException {
|
||||
stub.skipLower(playerUsername);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class RMIClient implements IClient {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) throws RemoteException {
|
||||
stub.pickOptionalTribeCard(playerUsername,pos);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class RMIClient implements IClient {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) throws RemoteException {
|
||||
stub.pickOptionalBuildingCard(playerUsername,pos);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class RMIClient implements IClient {
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void noOptionalCard(String playerUsername) {
|
||||
public void noOptionalCard(String playerUsername) throws RemoteException {
|
||||
stub.noOptionalCard(playerUsername);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class RMIClient implements IClient {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the selected slot
|
||||
*/
|
||||
public void slotChoice(String playerUsername,int pos) {
|
||||
public void slotChoice(String playerUsername,int pos) throws RemoteException {
|
||||
stub.slotChoice(playerUsername,pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,27 +8,27 @@ public interface IGameServer extends Remote {
|
||||
|
||||
boolean joinGame(String username,int preferredInt, IClientCallback callback) throws RemoteException;
|
||||
boolean doEvent(NetworkEvent event) throws RemoteException;
|
||||
void drawUpperTribeCard(String playerUsername, int pos) ;
|
||||
void drawUpperTribeCard(String playerUsername, int pos) throws RemoteException;
|
||||
|
||||
void drawLowerTribeCard(String playerUsername,int pos) ;
|
||||
void drawLowerTribeCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
void drawUpperBuildingCard(String playerUsername,int pos);
|
||||
void drawUpperBuildingCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
|
||||
void drawLowerBuildingCard(String playerUsername,int pos) ;
|
||||
void drawLowerBuildingCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
void skipUpper(String playerUsername) ;
|
||||
void skipUpper(String playerUsername) throws RemoteException;
|
||||
|
||||
void skipLower(String playerUsername) ;
|
||||
void skipLower(String playerUsername) throws RemoteException;
|
||||
|
||||
|
||||
void pickOptionalTribeCard(String playerUsername,int pos) ;
|
||||
void pickOptionalTribeCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
void pickOptionalBuildingCard(String playerUsername,int pos);
|
||||
void pickOptionalBuildingCard(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
|
||||
void noOptionalCard(String playerUsername) ;
|
||||
void noOptionalCard(String playerUsername) throws RemoteException;
|
||||
|
||||
void slotChoice(String playerUsername,int pos) ;
|
||||
void slotChoice(String playerUsername,int pos) throws RemoteException;
|
||||
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param callback The client's callback interface
|
||||
* @return true if the player successfully joined the game, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean joinGame(String username, int preferredInt, IClientCallback callback) {
|
||||
if (preferredInt<2 || preferredInt>5) {
|
||||
return false;
|
||||
@@ -106,7 +105,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param action The desired actio
|
||||
* @return true if the action was successfully added, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean doEvent(NetworkEvent action) {
|
||||
return actionQueue.offer(action);
|
||||
}
|
||||
@@ -117,9 +115,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
@Override
|
||||
public void drawUpperTribeCard(String playerUsername, int pos) {
|
||||
|
||||
actionQueue.offer(new DrawUpperTribeCard(playerUsername,pos));
|
||||
}
|
||||
|
||||
@@ -130,7 +126,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
@Override
|
||||
public void drawLowerTribeCard(String playerUsername,int pos) {
|
||||
actionQueue.offer(new DrawLowerTribeCard(playerUsername,pos));
|
||||
}
|
||||
@@ -142,7 +137,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
@Override
|
||||
public void drawUpperBuildingCard(String playerUsername,int pos) {
|
||||
actionQueue.offer(new DrawUpperBuildingCard(playerUsername,pos));
|
||||
}
|
||||
@@ -154,7 +148,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
@Override
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) {
|
||||
actionQueue.offer(new DrawLowerBuildingCard(playerUsername,pos));
|
||||
}
|
||||
@@ -165,7 +158,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* This action is available only when the upper list is empty or the player cannot draw any card.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
@Override
|
||||
public void skipUpper(String playerUsername) {
|
||||
actionQueue.offer(new SkipUpper(playerUsername));
|
||||
}
|
||||
@@ -176,7 +168,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* This action is available only when the lower list is empty or the player cannot draw any card.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
@Override
|
||||
public void skipLower(String playerUsername) {
|
||||
actionQueue.offer(new SkipLower(playerUsername));
|
||||
}
|
||||
@@ -188,7 +179,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
@Override
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||
actionQueue.offer(new PickOptionalTribeCard(playerUsername,pos));
|
||||
}
|
||||
@@ -200,7 +190,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
@Override
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
actionQueue.offer(new PickOptionalBuildingCard(playerUsername,pos));
|
||||
}
|
||||
@@ -211,7 +200,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
@Override
|
||||
public void noOptionalCard(String playerUsername) {
|
||||
actionQueue.offer(new NoOptionalCard(playerUsername));
|
||||
}
|
||||
@@ -222,7 +210,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the selected slot
|
||||
*/
|
||||
@Override
|
||||
public void slotChoice(String playerUsername,int pos) {
|
||||
actionQueue.offer(new SlotChoice(playerUsername,pos));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user