1 /* $OpenBSD: cribbage.h,v 1.12 2015/12/31 18:10:19 mestre Exp $ */ 2 /* $NetBSD: cribbage.h,v 1.3 1995/03/21 15:08:46 cgd Exp $ */ 3 4 /* 5 * Copyright (c) 1980, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)cribbage.h 8.1 (Berkeley) 5/31/93 33 */ 34 35 #include <curses.h> 36 #include <stdbool.h> 37 38 #include "deck.h" 39 40 extern CARD deck[ CARDS ]; /* a deck */ 41 extern CARD phand[ FULLHAND ]; /* player's hand */ 42 extern CARD chand[ FULLHAND ]; /* computer's hand */ 43 extern CARD crib[ CINHAND ]; /* the crib */ 44 extern CARD turnover; /* the starter */ 45 46 extern CARD known[ CARDS ]; /* cards we have seen */ 47 extern int knownum; /* # of cards we know */ 48 49 extern int pscore; /* player's score */ 50 extern int cscore; /* comp's score */ 51 extern int glimit; /* points to win game */ 52 53 extern int pgames; /* player's games won */ 54 extern int cgames; /* comp's games won */ 55 extern int gamecount; /* # games played */ 56 extern int Lastscore[2]; /* previous score for each */ 57 58 extern bool iwon; /* if comp won last */ 59 extern bool explain; /* player mistakes explained */ 60 extern bool muggins; /* player mistakes exploited */ 61 extern bool rflag; /* if all cuts random */ 62 extern bool quiet; /* if suppress random mess */ 63 extern bool playing; /* currently playing game */ 64 65 extern char expl_string[128]; /* string for explanation */ 66 67 void addmsg(const char *, ...); 68 int adjust(CARD [], CARD); 69 int anymove(CARD [], int, int); 70 int anysumto(CARD [], int, int, int); 71 void bye(void); 72 int cchose(CARD [], int, int); 73 void cdiscard(bool); 74 int chkscr(int *, int); 75 int comphand(CARD [], char *); 76 void cremove(CARD, CARD [], int); 77 int cut(bool, int); 78 int deal(bool); 79 void discard(bool); 80 void do_wait(void); 81 void endmsg(void); 82 int eq(CARD, CARD); 83 int fifteens(CARD [], int); 84 void game(void); 85 void gamescore(void); 86 char *get_line(void); 87 int getuchar(void); 88 int incard(CARD *); 89 int infrom(CARD [], int, char *); 90 void instructions(void); 91 int isone(CARD, CARD [], int); 92 void makeboard(void); 93 void makedeck(CARD []); 94 void makeknown(CARD [], int); 95 void msg(const char *, ...); 96 int msgcard(CARD, bool); 97 int msgcrd(CARD, bool, char *, bool); 98 int number(int, int, char *); 99 int numofval(CARD [], int, int); 100 int pairuns(CARD [], int); 101 int peg(bool); 102 int pegscore(CARD, CARD [], int, int); 103 int playhand(bool); 104 int plyrhand(CARD [], char *); 105 void prcard(WINDOW *, int, int, CARD, bool); 106 void prcrib(bool, bool); 107 void prhand(CARD [], int, WINDOW *, bool); 108 void printcard(WINDOW *, int, CARD, bool); 109 void prpeg(int, int, bool); 110 void prtable(int); 111 int readchar(void); 112 __dead void rintsig(int); 113 int score(bool); 114 int scorehand(CARD [], CARD, int, bool, bool); 115 void shuffle(CARD []); 116 void sorthand(CARD [], int); 117 void wait_for(int); 118