Fix: ServerRMI interface bug

This commit is contained in:
2026-05-05 16:46:55 +02:00
parent b5d0f70b41
commit 20ba64ea46
5 changed files with 97 additions and 61 deletions
@@ -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));
}