-/* $NetBSD: crib.c,v 1.19 2004/01/27 20:30:29 jsm Exp $ */
+/* $NetBSD: crib.c,v 1.25 2012/10/13 20:36:06 dholland Exp $ */
/*-
* Copyright (c) 1980, 1993
#include <sys/cdefs.h>
#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993\
+ The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: crib.c,v 1.19 2004/01/27 20:30:29 jsm Exp $");
+__RCSID("$NetBSD: crib.c,v 1.25 2012/10/13 20:36:06 dholland Exp $");
#endif
#endif /* not lint */
#include "cribcur.h"
#include "pathnames.h"
-int main(int, char *[]);
+static void makeboard(void);
+static void gamescore(void);
+static void game(void);
+static int playhand(BOOLEAN);
+static int deal(BOOLEAN);
+static void discard(BOOLEAN);
+static int cut(BOOLEAN, int);
+static void prcrib(BOOLEAN, BOOLEAN);
+static int peg(BOOLEAN);
+static void prtable(int);
+static int score(BOOLEAN);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
BOOLEAN playing;
FILE *f;
exit(1);
}
- initscr();
+ if (!initscr())
+ errx(0, "couldn't initialize screen");
(void)signal(SIGINT, receive_intr);
cbreak();
noecho();
* makeboard:
* Print out the initial board on the screen
*/
-void
-makeboard()
+static void
+makeboard(void)
{
mvaddstr(SCORE_Y + 0, SCORE_X,
"+---------------------------------------+");
* gamescore:
* Print out the current game score
*/
-void
-gamescore()
+static void
+gamescore(void)
{
if (pgames || cgames) {
mvprintw(SCORE_Y + 1, SCORE_X + 28, "Games: %3d", pgames);
* Play one game up to glimit points. Actually, we only ASK the
* player what card to turn. We do a random one, anyway.
*/
-void
-game()
+static void
+game(void)
{
int i, j;
BOOLEAN flag;
if (!rflag) { /* player cuts deck */
msg(quiet ? "Cut for crib? " :
"Cut to see whose crib it is -- low card wins? ");
- getline();
+ get_line();
}
i = (rand() >> 4) % CARDS; /* random cut */
do { /* comp cuts deck */
* playhand:
* Do up one hand of the game
*/
-int
-playhand(mycrib)
- BOOLEAN mycrib;
+static int
+playhand(BOOLEAN mycrib)
{
int deckpos;
/*
* deal cards to both players from deck
*/
-int
-deal(mycrib)
- BOOLEAN mycrib;
+static int
+deal(BOOLEAN mycrib)
{
int i, j;
* Handle players discarding into the crib...
* Note: we call cdiscard() after prining first message so player doesn't wait
*/
-void
-discard(mycrib)
- BOOLEAN mycrib;
+static void
+discard(BOOLEAN mycrib)
{
const char *prompt;
CARD crd;
* Cut the deck and set turnover. Actually, we only ASK the
* player what card to turn. We do a random one, anyway.
*/
-int
-cut(mycrib, pos)
- BOOLEAN mycrib;
- int pos;
+static int
+cut(BOOLEAN mycrib, int pos)
{
int i;
BOOLEAN win;
if (!rflag) { /* random cut */
msg(quiet ? "Cut the deck? " :
"How many cards down do you wish to cut the deck? ");
- getline();
+ get_line();
}
i = (rand() >> 4) % (CARDS - pos);
turnover = deck[i + pos];
* prcrib:
* Print out the turnover card with crib indicator
*/
-void
-prcrib(mycrib, blank)
- BOOLEAN mycrib, blank;
+static void
+prcrib(BOOLEAN mycrib, BOOLEAN blank)
{
int y, cardx;
* Handle all the pegging...
*/
static CARD Table[14];
-static int Tcnt;
+static unsigned Tcnt;
-int
-peg(mycrib)
- BOOLEAN mycrib;
+static int
+peg(BOOLEAN mycrib)
{
static CARD ch[CINHAND], ph[CINHAND];
int i, j, k;
* prtable:
* Print out the table with the current score
*/
-void
-prtable(score)
- int score;
+static void
+prtable(int curscore)
{
prhand(Table, Tcnt, Tablewin, FALSE);
- mvwprintw(Tablewin, (Tcnt + 2) * 2, Tcnt + 1, "%2d", score);
+ mvwprintw(Tablewin, (Tcnt + 2) * 2, Tcnt + 1, "%2d", curscore);
wrefresh(Tablewin);
}
* score:
* Handle the scoring of the hands
*/
-int
-score(mycrib)
- BOOLEAN mycrib;
+static int
+score(BOOLEAN mycrib)
{
sorthand(crib, CINHAND);
if (mycrib) {