/* *Some of the internal datatypes used * Copyright (C) 2005 Joseph Pingenot This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /*Size of nick buffer, WITH final '\0'. */ #define NICKBUFF 51 /*Size of the reply argument buffer. This effectively limits the size of a message*/ #define ARGBUFF 254 /*Card suits*/ enum suits {DIAMONDS, HEARTS, SPADES, CLUBS}; enum faces {ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING}; struct player; struct card { enum suits suit; enum faces face; unsigned short int used; /*Card is held by a player, crib, or is top*/ struct player *owner; /*Pointer to card's owner*/ }; struct player { char nick[NICKBUFF]; /*player's nickname (+ '\0'!)*/ int fd; /*file descriptor for their link*/ struct card *cards[6]; /*Pointers to the cards they have in their hand (max 6)*/ unsigned short int dealer; /*Dealer flag: 1 if they are, 0 if they aren't*/ unsigned short int mugcheck; /*Muggins check (means this user may not call muggins this go-round*/ unsigned short int agree; /*Does this user agree?*/ unsigned short int used_cards; /*Which cards have been used in play*/ unsigned int score; /*User's score in the game*/ unsigned short int active; /*Player is currently active*/ /*We don't need a control_player field; player[0] is always control player. Duh.*/ }; enum phases {INTRODUCTION, WAITING, HANDSETUP, PLAY, COUNT, PAUSE, USERPAUSE, MUGGINS, ENDGAME}; /*This holds the whole game state*/ struct game { enum phases phase; /*Our current phase*/ struct player players[4]; /*All the players (max 4, min 2)*/ struct card cards[52]; /*The deck*/ struct card *topcard; /*Pointer to the top card*/ struct card *crib[4]; /*Dealer's crib*/ unsigned short int tally; /*The current tally (for the play; max is 30 (resets @ 31)*/ int n; /*Number of players in the game*/ struct cribserv_options *opts; /*Game options*/ }; /*Initialize the game*/ void init_game(struct cribserv_options *opts, struct game *g); /*Resets counters for the next loop (play + coutning session); called at the * start of the hand filtering stage*/ void reset_loop(struct game *g); /*This doesn't erase a player; it just sets up the player's slot for a new player *this should be called when a player quits. */ void void_player(struct game *g, struct player *p); /*Copies a player*/