Example #1
0
  /** Get ready for a new game, given a letter list specification of the Boggle board. */
  public void newGame() {
    myBoard = BoggleBoardFactory.getBoard(myBoardSize);
    mySeconds = 0;
    myProgress.setValue(0);

    // set up views for new game

    if (myBoardSize == 4) {
      if (myBoardPanel != myBoardPanel4) {
        myBoardPanel = myBoardPanel4;
        getContentPane().remove(myBoardPanel5);
        getContentPane().add(myBoardPanel, BorderLayout.CENTER);
      }
    } else {
      if (myBoardPanel != myBoardPanel5) {
        myBoardPanel = myBoardPanel5;
        getContentPane().remove(myBoardPanel4);
        getContentPane().add(myBoardPanel, BorderLayout.CENTER);
      }
    }

    myBoardPanel.newGame();
    humanArea.setReady();
    computerArea.setReady();
    myBoardPanel.unHighlightAllDice();
    wordEntryField.setReady();
    ((JPanel) getContentPane()).revalidate();
    repaint();
    myTimer.start();
  }
Example #2
0
  /** Let the computer player take its turn. */
  public void computerPlay() {
    computerArea.setName("Thinking!");
    computerArea.paintImmediately(computerArea.getVisibleRect());
    int minLength = myBoardSize == 4 ? 3 : 4;
    computerPlayer.findAllValidWords(myBoard, myLexicon, minLength);

    computerArea.setName("Computer");
    for (String s : computerPlayer) {
      computerArea.showWord(s, myFinder.cellsForWord(myBoard, s), computerPlayer);
    }
    myBoardPanel.unHighlightAllDice(); // leave board unhighlighted when
    // done
  }