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