home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
games
/
volume13
/
okbridge
/
part06
/
input.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-12
|
8KB
|
232 lines
/* input.h -- interface for input module of bridge game.
!
! Copyright (C) 1990,1991 by Matthew Clegg
!
! This program may be copied and distributed freely. Please do not
! charge money for this program or for any program derived from it.
! If you modify this program, then include a notice stating plainly
! that your program is derived from the okbridge program and is not
! the same as the official okbridge program.
!
! I welcome any suggestions for improvement to okbridge, and
! I would be especially happy to receive improved source code.
! If you have comments or suggestions, or if you would like to
! join the okbridge mailing list, then write to
!
! mclegg@cs.ucsd.edu
!
*
* This file defines the routines for handling the player-input
* in the bridge game.
*
*/
/* The main job of the input module is to return a record indicating
. a player's input. However, the input module also controls
. some of the bookkeeping and communications aspects of the game. The
. commands having index 100 or greater are handled internally to the
. input module and are not ever passed back to the calling routines.
*/
#define CMD_ERROR 000
#define CMD_VULN 001
#define CMD_RDEAL 002
#define CMD_BID 004
#define CMD_PLAY 010
#define CMD_FINISH 020
#define CMD_HELLO 0000000100
#define CMD_ACK 0000000200
#define CMD_TALK 0000000400
#define CMD_HELP 0000001000
#define CMD_QUIT 0000002000
#define CMD_BELL 0000004000
#define CMD_PING 0000010000
#define CMD_ECHO 0000020000
#define CMD_PROMPT 0000040000
#define CMD_CLAIM 0000100000
#define CMD_RESP 0000200000
#define CMD_SCORE 0000400000
#define CMD_LOG 0001000000
#define CMD_DEAL 0002000000
#define CMD_LOAD 0004000000
#define CMD_SAVE 0010000000
#define CMD_REPLAY 0020000000
#define CMD_COMMENT 0040000000
#define CMD_DEFAULT 0100000000
#define CMD_REVIEW 0200000000
/* #define MAX_COMMANDS 25 */
#define VERSION_LENGTH 10
#define VERSION_NAME_LENGTH 20
#define MESSAGE_LENGTH 75
#define TOPIC_LENGTH 20
#define FILENAME_LENGTH 60
typedef struct player_command_struct {
long command;
int player_no;
union {
int bid;
int card;
char deal [52];
char version_name [VERSION_NAME_LENGTH];
char message [MESSAGE_LENGTH];
char topic [TOPIC_LENGTH];
char filename [FILENAME_LENGTH];
int bell;
int ping_source;
int prompt;
int tricks;
int response;
int scoring;
int nhands;
int vulnerable;
int defaalt;
} data;
} *player_command;
typedef struct input_buffer_struct {
char buf[91];
int row, col, length; /* aspects of the screen display. */
int pos; /* cursor position in buffer. */
int defaulted; /* true if input buffer contains the
default input. */
} *input_buffer;
#ifndef _INPUT_
extern parse_player_command ();
/* void parse_player_command (parse_string ps, player_command pc); */
/* parse the string ps into a player command, which is stored in pc.
* If an error is encountered, then an error message is stored in the
* global variable parsing_errmsg.
*
* The syntax of a player command is as follows:
*
* 0. VULN NONE | EW | NS | BOTH
* 1. RDEAL <cards>
* 2. BID (<level> (<suit> | <notrump>)) | <pass> | <double> | <redouble>
* 3. PLAY <suit> <card>
* 4. CLAIM <ntricks>
* 5. FINISH YES | NO
* 6. TALK message
* 7. HELLO version name
* 8. ACK version name
* 9. HELP [topic]
* 10. BELL [ON | OFF]
* 11. PROMPT [ON | OFF]
* 12. PING
* 13. ECHO [player]
* 14. SCORE mode
* 15. LOG <log-file>
* 16. DEAL [nhands]
* 17. LOAD filename
* 18. SAVE filename
* 19. REPLAY filename
* 20. COMMENT broadcast-message
* 21. QUIT
*
* where:
* <cards> = A string over the alphabet {0,1,2,3} containing exactly
* thirteen occurrences of each symbol.
* <level> = 1 | 2 | 3 | 4 | 5 | 6 | 7
* <suit> = C | D | H | S | CLUB[S] | DIAMOND[S] | HEART[S] | SPADE[S]
* <notrump> = N | NT | NOTRUMP
* <pass> = P | PASS
* <double> = X | DOUBLE
* <redouble> = XX | REDOUBLE
* <card> = <suit> <rank>
* <rank> = 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | T | J | Q | K
* | JACK | KING | QUEEN
* <tricks> = an integer in the range 0 - 13.
* <version> = a string indicating the revision level of the program
* <name> = the name of a player
* <player> = NORTH | EAST | SOUTH | WEST
* <mode> = RUBBER | CHICAGO
*/
extern clear_input_buffer ();
/* void clear_input_buffer (input_buffer ib); */
/* Clears the screen display representing the input buffer, and
* resets the cursor position to the beginning of the buffer.
*/
extern int update_input_buffer ();
/* int update_input_buffer (input_buffer ib, int ch); */
/* Adds the character ch to the input buffer, or if it is a control
* character, then modifies the cursor position or buffer appropriately.
* If the user has indicated he is through entering input, by entering
* i.e. <^J> or <^M>, then TRUE is returned. Otherwise, FALSE is
* returned. The other control characters which are accepted at this
* point are:
* <^H> causes last character in buffer to be erased.
* <^R> causes the screen to be refreshed.
* <DEL> causes last character in buffer to be erased.
* <ESC> causes entire buffer to be erased.
* Printable characters are entered into the buffer if there is room.
* All other characters are ignored.
*/
extern Initialize_Input ();
/* void Initialize_Input (void); */
/* This routine should be called once when the program first begins,
* in order to set up the input buffers correctly.
*/
extern input_hand ();
/* void input_hand (deal new_deal); */
/* Inputs a new deal into the data structure 'new_deal'. If the dealer
* is the local_player, then the deck is shuffled locally and the deal
* is messaged to the other players. Otherwise, we wait for the other
* players to send us the new deal.
*/
extern int input_bid ();
/* int input_bid (int rmt_player, int minimum_bid, int double_ok,
int redouble_ok); */
/* Inputs a bid from the player 'rmt_player'. If rmt_player is the
* local player, then we only accept a contract bid which is at least as
* high as minimum_bid, and we only accept a double or redouble bid if
* respectively double_ok and redouble_ok is true. However, if rmt_player
* is not the local player, then we wait for the bid to come from the
* network. In this case, we assume that the bid we receive is legal.
*/
extern int input_play ();
/* int input_play (int rmt_player, hand legal_plays); */
/* Inputs a play from the player 'rmt_player'. If rmt_player is the
* local player, then we only accept a play which is listed as one of the
* cards in 'legal_plays'. However, if rmt_player is not the local player,
* then we wait for the play to come from the network. In this case, we
* assume that the play is legal. If the return value is non-negative,
* then it indicates the card which has been played. Otherwise,
* the return value is of the form -k-1, where k is the number of
* additional tricks conceded to the declaring team in this hand.
*/
extern input_acknowledgement ();
/* void input_acknowledgment (int line); */
/* Displays the message "PRESS RETURN TO CONTINUE" on the given screen line,
* unless line == -1, in which case the message is displayed on the
* status line. Then waits for the user to press, RETURN.
*/
extern send_player_message ();
/* send_player_message (char *message); */
/* Transmits the message to the other players through the network.
* Prepends the name of the player to the message before transmitting.
*/
extern Broadcast_Comment ();
/* Broadcase_Comment (char *message); */
/* Transmits the message to the other players as a comment which is
* displayed in the talk window.
*/
#endif