/** * Pseudocode for the Othello GUI * @author Greg Fuller * @author Ellen Gallagher * @author Jill Lofchie * @author Dave Wingate * March 1, 2000 */ public class OthelloGUI extends WindowAdapter implements ActionListener { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** * We are going to have some fields here, they'll look something like * this: */ /** The frame that will display the board and important information. */ protected Frame main; /** The button that you press to end the program. */ protected Button quit; /** field for the Boardtype that will be associated with this game * (the constructor for this class should have a rules field) */ protected Board board /** there will be a bunch of other fields and stuff, see the picture */ /** There will also need to be some totally seperate windows that are * launched from the beginning and will prompt the user for the variants * on the game rules, number of players, etc. We didn't write this yet * because we don't know what the different options will be yet * We will, however, need constructors for all of these options so that we * can initialize them in the correct way once we know how the user wants * them. */ // +----------------+----------------------------------------- // | Constructors | // +----------------+ /** * We'll write this.. later, it involves creating our windows and adding * spiffy objects to them. */ // +----------------+----------------------------------------- // | Event Handlers | // +----------------+ /** * We figured the action listeners for all the buttons and objects we * have in our main window are the most important things, and all the * things that require calling other peoples' methods. */ /** Action Listener for the quit button will call: */ { main.dispose(); System.exit(0); } /** Action Listener for the help button will call: */ { // helptext is a window with the rules and suggestions for how to play // it may need to be different when playing under different games. helptext.show(); } /** Action Listener for the undo button will call: */ // We need the board people to write a method that undoes the last move or, // in the case of a computer/human game, the last two moves, if the // computer has gone. { board.undoLastMove(); GUIboard.update(); } /** Action Listener for the options button */ { // opens the window with the options in it optionswindow.show(); } /** Action Listener for the Show Last Move button */ { // Highlights the places on the board that were recently flipped // The board class will need a LastMove() method that returns an // array of the pieces that were added and changed. GUIboard.highlight(board.LastMove()); } /** Action Listener for the GUI board */ { // The rules class tells us if the place played is legal. if !(rules.legalMove(x,y,player.currentColor())) // if the move was not legal { out.setText(textobject.illegalMove()) } // if else { // the move was legal // GUIboard.update takes an array of coordinates and concult the board // object for information about the pieces at each of those // coordinates and make the appropriate changes on the GUIboard GUIboard.update( board.move(x,y,player.currentColor()) ); // report to board the creation of a new piece object, then use some // method of the rules class to decide which pieces to flip subsequently // additionally, this method should return an array of coordinates // of the pieces that have been flipped player.nextPlayer(); // this should start with an index = to the number of player,check to // see that this next player has a legal move, if not, decrease the index // by one and check for the next possible player. if the index reaches // zero, then the game is over out.setText(textobject.promptPlayer()); } // else } // Action Listener for the GUI Board