user_interface
= cluster is create, destroy, display_board, display_message, await_command, command_waiting, display_move, wait_long_process,
finish_long_process
- Overview
- user_interface is a data structure which encapsulates the user interface for chess/antichess. It handles only the *interface* for displaying the board, making moves, etcetera and doesn't make any decisions of its own...it is called by the arbiter.
- written by stevenj, twm, pepellet
- $Log: user_interface.spec.html,v $
- Revision 1.1 2001/01/12 02:23:24 twm
- Revision as of January 11, 2001.
- Revision 1.2 95/04/16 15:55:16 pepellet fixed await_command to send waiting_for_long_process signal
- Revision 1.1 95/04/15 20:24:17 pepellet Initial revision
- create = proc() returns(cvt)
- effects: returns a new ui data structure, doing any required initializations (opening windows, etc.)
- destroy = proc(ui: cvt)
- requires: destroy has not been called on ui yet.
- effects: destroys the user interface ui, closing windows, etc.
- display_board = proc(ui: cvt, board: chess_board)
- requires: destroy has not been called on ui yet.
- effects: displays the contents of board to the user
- display_message = proc(ui: cvt, message: string)
- requires: destroy has not been called on ui yet.
- effects: displays the string, message, to the user in some way
- await_command = proc(ui: cvt, board: chess_board, cur_color: pieceColor, gs: game_state)
returns(ui_command) signals(waiting_for_long_process)
- requires: destroy has not been called on ui yet.
- effects: Waits for a command from the user, and returns the information necessary to execute the command. Does *not* execute the command itself. board is provided in case ui needs to refresh the board display. cur_color is the color the current player's pieces. gs is the current game state. Must support the text-based input described in the problem set handout, in addition to any other input methods. If the current player's time elapses without anything happening, should return a timeout command. If a long process is currently waiting, signals waiting_for_long_process.
- command_waiting = proc(ui: cvt) returns(bool)
- requires: destroy has not been called on ui yet
- effects: returns true if there is currently a command waiting to be read by await_command. returns false otherwise.
- display_move = proc(ui: cvt, board: chess_board, move: moveData, the_player: string)
signals(no_piece, illegal_location)
- requires: destroy has not been called on ui yet
- effects: Displays the effect of the move described in move; board is the chess_board *before* the move occurs. the_player is the name of the player making the move. If there is no piece at the starting point of the move, signals no_piece. If the coordinates in move are not locations on the board, signals illegal_location. (Does *not* check if the move itself is legal).
- wait_long_process = proc(ui: cvt, message: string)
- requires: destroy has not been called on ui yet
- effects: displays the message string in preparation for a long process to start. If await_command is called before finish_long_process is called, the user interface will *not* allow or return any user commands. wait_long_process may be called more than once before finish_long_process is called, with different message strings.
- finish_long_process = proc(ui: cvt) signals(not_waiting)
- requires: destroy has not been called on ui yet
- effects: after call(s) to wait_long_process, stops displaying message string(s) and resumes normal operation of the interface. Signals not_waiting if there was no call to wait_long_process since the last call to finish_long_process.