private void newGame() { NewGameDialog ngd = new NewGameDialog(); goc = new GameOfCluedo(); goc.startGame(ngd.getPlayers("New Game")); can_board.setBoard(goc.getBoard()); showButtons(); enableButtons(); btn_guess.setEnabled(false); ImageIcon img = new ImageIcon(myPicture[goc.getCurrentPlayer().getCharacter().ordinal()]); picLabel.setIcon(img); txt_name.setText(goc.getCurrentPlayer().getName()); // JOptionPane.showMessageDialog(this, goc.getCurrentPlayer().getName() + "'s Turn"); repaint(); }
private void accusePressed() { GuessDialog ac = new GuessDialog(); if (goc.accuse(ac.getGuess("Accuse"))) { System.out.println("You win"); goc.setWinner(goc.getCurrentPlayer()); // Correct set winner and end game endTurn(); } else { System.out.println("You lost"); String playerName = goc.getCurrentPlayer().getName(); goc.playerLost(goc.getCurrentPlayer()); // Wrong remove player from play endTurn(); if (goc != null && !goc.checkGameOver()) { can_board.setBoard(goc.getBoard()); JOptionPane.showMessageDialog(this, playerName + " has been eliminated"); } } }
private void movePressed() { if (!moveSelected && goc.canMove()) { goc.die.roll(); lbl_dice.setIcon(goc.die.getDiceIcon()); if (goc.highlightValidMoves()) { btn_guess.setEnabled(false); btn_accuse.setEnabled(false); moveSelected = true; can_board.setBoard(goc.getBoard()); } else { btn_move.setEnabled(false); JOptionPane.showMessageDialog(this, " There are no valid moves"); if (!goc.getPlayerPos().isRoom()) { endTurn(); } } } }
private void endTurn() { if (goc.checkGameOver()) { showGameOver(); return; } goc.endTurn(); can_board.setBoard(goc.getBoard()); ImageIcon img = new ImageIcon(myPicture[goc.getCurrentPlayer().getCharacter().ordinal()]); picLabel.setIcon(img); txt_name.setText(goc.getCurrentPlayer().getName()); // if new player not in room disable guess if (!goc.getPlayerPos().isRoom()) { btn_guess.setEnabled(false); } else { btn_guess.setEnabled(true); } btn_move.setEnabled(true); // JOptionPane.showMessageDialog(this, goc.getCurrentPlayer().getName() + "'s Turn"); }