-/* $NetBSD: crib.c,v 1.5 1995/03/21 15:08:42 cgd Exp $ */
+/* $NetBSD: crib.c,v 1.9 1997/10/11 02:44:30 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1980, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: crib.c,v 1.5 1995/03/21 15:08:42 cgd Exp $";
+__RCSID("$NetBSD: crib.c,v 1.9 1997/10/11 02:44:30 lukem Exp $");
#endif
#endif /* not lint */
#include <curses.h>
+#include <err.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include "cribcur.h"
#include "pathnames.h"
+int main __P((int, char *[]));
+
int
main(argc, argv)
int argc;
FILE *f;
int ch;
- while ((ch = getopt(argc, argv, "eqr")) != EOF)
+ while ((ch = getopt(argc, argv, "eqr")) != -1)
switch (ch) {
case 'e':
explain = TRUE;
playing = (getuchar() == 'Y');
} while (playing);
- if (f = fopen(_PATH_LOG, "a")) {
+ if ((f = fopen(_PATH_LOG, "a")) != NULL) {
(void)fprintf(f, "%s: won %5.5d, lost %5.5d\n",
getlogin(), cgames, pgames);
(void) fclose(f);
}
bye();
- if (!f) {
- (void) fprintf(stderr, "\ncribbage: can't open %s.\n",
- _PATH_LOG);
- exit(1);
- }
+ if (!f)
+ errx(1, "can't open %s", _PATH_LOG);
exit(0);
}
void
game()
{
- register int i, j;
+ int i, j;
BOOLEAN flag;
BOOLEAN compcrib;
+ compcrib = FALSE;
makedeck(deck);
shuffle(deck);
if (gamecount == 0) {
} else
compcrib = (deck[i].rank > deck[j].rank);
} while (flag);
+ do_wait();
clear();
makeboard();
refresh();
} else {
+ makeboard();
+ refresh();
werase(Tablewin);
wrefresh(Tablewin);
werase(Compwin);
playhand(mycrib)
BOOLEAN mycrib;
{
- register int deckpos;
+ int deckpos;
werase(Compwin);
+ wrefresh(Compwin);
+ werase(Tablewin);
+ wrefresh(Tablewin);
knownum = 0;
deckpos = deal(mycrib);
deal(mycrib)
BOOLEAN mycrib;
{
- register int i, j;
+ int i, j;
for (i = j = 0; i < FULLHAND; i++) {
if (mycrib) {
discard(mycrib)
BOOLEAN mycrib;
{
- register char *prompt;
+ char *prompt;
CARD crd;
prcrib(mycrib, TRUE);
BOOLEAN mycrib;
int pos;
{
- register int i;
+ int i;
BOOLEAN win;
win = FALSE;
prcrib(mycrib, blank)
BOOLEAN mycrib, blank;
{
- register int y, cardx;
+ int y, cardx;
if (mycrib)
cardx = CRIB_X;
for (y = CRIB_Y; y <= CRIB_Y + 5; y++)
mvaddstr(y, cardx, " ");
+ refresh();
}
/*
BOOLEAN mycrib;
{
static CARD ch[CINHAND], ph[CINHAND];
- register int i, j, k;
- register int l;
- register int cnum, pnum, sum;
- register BOOLEAN myturn, mego, ugo, last, played;
+ int i, j, k;
+ int l;
+ int cnum, pnum, sum;
+ BOOLEAN myturn, mego, ugo, last, played;
CARD crd;
+ played = FALSE;
cnum = pnum = CINHAND;
for (i = 0; i < CINHAND; i++) { /* make copies of hands */
ch[i] = chand[i];
else { /* give him his point */
msg(quiet ? "You get one" :
"You get one point");
+ do_wait();
if (chkscr(&pscore, 1))
return TRUE;
sum = 0;
if (i > 0) {
msg(quiet ? "You got %d" :
"You got %d points", i);
+ if (pnum == 0)
+ do_wait();
if (chkscr(&pscore, i))
return TRUE;
}
} else {
msg(quiet ? "You get one for last" :
"You get one point for last");
+ do_wait();
if (chkscr(&pscore, 1))
return TRUE;
}
do_wait();
if (comphand(crib, "crib"))
return (TRUE);
+ do_wait();
} else {
if (comphand(chand, "hand"))
return (TRUE);