Skip to content
This repository was archived by the owner on Aug 9, 2022. It is now read-only.

Commit 6040441

Browse files
Merge pull request #56 from alexandrehassan/FixIssues
Fix issues
2 parents 2a41ebf + 769c34b commit 6040441

File tree

7 files changed

+214
-341
lines changed

7 files changed

+214
-341
lines changed

Risk/src/GameController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public void mousePressed(MouseEvent e) {
4848
}
4949

5050
String clickedCountry = (String) ((mxCell) cell).getValue();
51+
52+
if (clickedCountry.equals("")) {
53+
return;
54+
}
55+
5156
if (!gameModel.playerOwns(clickedCountry) && state != ATTACK_STATE) {
5257
JOptionPane.showMessageDialog(null, "Current player does not own " + clickedCountry);
5358
return;

Risk/src/GameFrame.java

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -479,57 +479,6 @@ public void handleGameOver(GameOverEvent gameOverEvent) {
479479
JOptionPane.showMessageDialog(this, gameOverEvent.getWinner().getName() + " won the Game");
480480
}
481481

482-
@Override
483-
public void handleMessageShow(GameShowEvent gameShowEvent) {
484-
JOptionPane.showMessageDialog(null, gameShowEvent.getMessage());
485-
}
486-
487-
@Override
488-
public int getIntInput(GetIntInputEvent getIntInputEvent) {
489-
return Integer.parseInt((String) JOptionPane.showInputDialog(
490-
null,
491-
getIntInputEvent.getMessage(),
492-
getIntInputEvent.getTitle(),
493-
JOptionPane.PLAIN_MESSAGE,
494-
null,
495-
null,
496-
""));
497-
}
498-
499-
@Override
500-
public LinkedList<String> getPlayerNames() {
501-
ArrayList<JTextField> playerInput = new ArrayList<>();
502-
for (int i = 0; i < 6; i++) {
503-
playerInput.add(new JTextField());
504-
}
505-
506-
Object[] message = {
507-
"Player 1", playerInput.get(0),
508-
"Player 2", playerInput.get(1),
509-
"Player 3", playerInput.get(2),
510-
"Player 4", playerInput.get(3),
511-
"Player 5", playerInput.get(4),
512-
"Player 6", playerInput.get(5),
513-
};
514-
LinkedList<String> currentPlayers = new LinkedList<>();
515-
int option = JOptionPane.showConfirmDialog(null, message, "Add players", JOptionPane.OK_CANCEL_OPTION);
516-
if (option == JOptionPane.OK_OPTION) {
517-
String playerName;
518-
for (JTextField jTextField : playerInput) {
519-
playerName = jTextField.getText().trim();
520-
if (!playerName.equals("")) {
521-
currentPlayers.add(playerName);
522-
}
523-
}
524-
}
525-
return currentPlayers;
526-
}
527-
528-
@Override
529-
public void ShowErrorPopUp(Exception e) {
530-
JOptionPane.showMessageDialog(null, e.getMessage());
531-
}
532-
533482
public void handleStateUpdate(PlayerStateEvent playerState) {
534483
playersInfo.get(playerState.getOrder()).setText(playerState.getInfo());
535484
}

0 commit comments

Comments
 (0)