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 guessPressed() {
   GuessDialog gs = new GuessDialog();
   assert goc.getPlayerPos().isRoom();
   Card shownCard = goc.guess(gs.getGuess("Guess", goc.getPlayerPos().getRoom().getName()));
   if (shownCard != null) {
     System.out.println("show card");
     List<Card> cardList = new ArrayList<Card>();
     cardList.add(shownCard);
     new ShowCardsFrame(
         cardList,
         "You were shown the " + shownCard.getTitle() + " card!",
         "You were shown the "
             + shownCard.getTitle()
             + " card!\n"
             + "This card cannot be in the envelope!");
   }
   endTurn();
 }
  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();
        }
      }
    }
  }
  public boolean showGameOver() {
    int popup = 0;
    if (goc.getWinner() == null) {
      popup =
          JOptionPane.showConfirmDialog(
              null,
              "Game Over!\nAll players eliminated.\n\nDo you want to play again?",
              "Game Over",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE);
    } else {
      popup =
          JOptionPane.showConfirmDialog(
              null,
              "Game Over!\n"
                  + goc.getWinner().getName()
                  + " has guessed the envelope.\n\nDo you want to play again?",
              goc.getWinner().getName() + " Won",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE);
    }

    if (popup == JOptionPane.YES_OPTION) {
      newGame();
      return true;
    } else {
      goc = null;
      can_board.setBoard(null);
      picLabel.setIcon(new ImageIcon(myPicture[myPicture.length - 1]));
      txt_name.setText("Dr. Black");
      disableButtons();
      hideButtons();
      repaint();
    }
    return false;
  }
  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!");
 }