Added: ErrorType.toString
This commit is contained in:
@@ -39,7 +39,7 @@ public class ApplyNextRound extends NetworkEvent implements Serializable{
|
||||
* @param players the list of players in the game.
|
||||
*/
|
||||
public ApplyNextRound(Map<Slot, Player> slotPlayerMap, OrderLogicCard orderLogicCard, CurrentState currentState, List<Player> players, ArrayList<TribeCard> upperListTribeCards, ArrayList<TribeCard>lowerListTribeCards, ArrayList<BuildingCard> upperListBuildingCards, ArrayList<BuildingCard>lowerListBuildingCards) {
|
||||
super("SERVER",EventType.NEXT_ROUND,false, ErrorType.WRONG_GAME_ACTION);
|
||||
super("SERVER",EventType.NEXT_ROUND,false, ErrorType.WRONG_ACTION);
|
||||
this.upperListBuildingCards = upperListBuildingCards;
|
||||
this.lowerListBuildingCards = lowerListBuildingCards;
|
||||
this.upperListTribeCards = upperListTribeCards;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DrawLowerBuildingCard extends NetworkEvent implements Serializable
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public DrawLowerBuildingCard(String username, int pos){
|
||||
super(username, EventType.DRAW_LOWER_BUILD, false, ErrorType.WRONG_GAME_ACTION);
|
||||
super(username, EventType.DRAW_LOWER_BUILD, false, ErrorType.WRONG_ACTION);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DrawLowerTribeCard extends NetworkEvent implements Serializable{
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public DrawLowerTribeCard(String username, int pos){
|
||||
super(username, EventType.DRAW_LOWER_TRIBE, false, ErrorType.WRONG_GAME_ACTION);
|
||||
super(username, EventType.DRAW_LOWER_TRIBE, false, ErrorType.WRONG_ACTION);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DrawUpperBuildingCard extends NetworkEvent implements Serializable
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public DrawUpperBuildingCard(String username, int pos){
|
||||
super(username, EventType.DRAW_UPPER_BUILD, false, ErrorType.WRONG_GAME_ACTION);
|
||||
super(username, EventType.DRAW_UPPER_BUILD, false, ErrorType.WRONG_ACTION);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DrawUpperTribeCard extends NetworkEvent implements Serializable{
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public DrawUpperTribeCard(String username, int pos){
|
||||
super(username, EventType.DRAW_UPPER_TRIBE, false, ErrorType.WRONG_GAME_ACTION);
|
||||
super(username, EventType.DRAW_UPPER_TRIBE, false, ErrorType.WRONG_ACTION);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SkipTurn extends NetworkEvent implements Serializable{
|
||||
* @param username the name of the player requesting the event
|
||||
*/
|
||||
public SkipTurn(String username){
|
||||
super(username, EventType.SKIP_TURN, false, ErrorType.WRONG_GAME_ACTION);
|
||||
super(username, EventType.SKIP_TURN, false, ErrorType.WRONG_ACTION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SlotChoice extends NetworkEvent implements Serializable {
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public SlotChoice(String username, int pos) {
|
||||
super(username, EventType.SLOT_CHOICE, false, ErrorType.WRONG_GAME_ACTION);
|
||||
super(username, EventType.SLOT_CHOICE, false, ErrorType.WRONG_ACTION);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TotemChoice extends NetworkEvent implements Serializable {
|
||||
* @param totem the name of the selected totem.
|
||||
*/
|
||||
public TotemChoice(String username, String totem) {
|
||||
super(username, EventType.TOTEM_CHOICE, false, ErrorType.WRONG_GAME_ACTION);
|
||||
super(username, EventType.TOTEM_CHOICE, false, ErrorType.WRONG_ACTION);
|
||||
this.totem = totem;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ClientCallbackImpl extends UnicastRemoteObject implements IClientCa
|
||||
@Override
|
||||
public void onAction(NetworkEvent event) throws RemoteException {
|
||||
if(event.getIsError()) {
|
||||
clientController.view.showError(event.getErrorType());
|
||||
clientController.view.showError(event.getErrorType(),event.toString());
|
||||
} else {
|
||||
event.apply(clientController.miniModel);
|
||||
clientController.view.render();
|
||||
|
||||
@@ -126,7 +126,7 @@ public class RMIClient implements IClient {
|
||||
if (!running) return;
|
||||
running = false;
|
||||
if (pingSender != null) pingSender.shutdownNow();
|
||||
controller.view.showError(ErrorType.SERVER_CRASHED);
|
||||
controller.view.showError(ErrorType.SERVER_CRASHED,ErrorType.SERVER_CRASHED.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ public class TCPClient implements IClient {
|
||||
running = false;
|
||||
try { communicationSocket.close(); } catch (IOException ignored) {}
|
||||
try { heartbeatSocket.close(); } catch (IOException ignored) {}
|
||||
controller.view.showError(ErrorType.SERVER_CRASHED);
|
||||
controller.view.showError(ErrorType.SERVER_CRASHED,ErrorType.SERVER_CRASHED.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,11 @@ public class TCPClient implements IClient {
|
||||
|
||||
if (read instanceof NetworkEvent event) {
|
||||
if (event.getIsError()) {
|
||||
controller.view.showError(event.getErrorType());
|
||||
if(event.getErrorType() == ErrorType.WRONG_ACTION) {
|
||||
controller.view.showError(ErrorType.WRONG_ACTION,event.toString());
|
||||
}
|
||||
else
|
||||
controller.view.showError(event.getErrorType(),event.getErrorType().toString());
|
||||
} else {
|
||||
event.apply(controller.miniModel);
|
||||
controller.view.render();
|
||||
|
||||
Reference in New Issue
Block a user