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 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"); }
private void showCards() { new ShowCardsFrame( goc.getCurrentPlayer().gethand(), goc.getCurrentPlayer().getName() + "'s Hand!"); }