]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - cribbage/crib.c
use CPPFLAGS instead of CFLAGS
[bsdgames-darwin.git] / cribbage / crib.c
index 96bfe568e768df565ea6f1e570676a174c3d81a7..ce8778f4d3451700aa1d231151bd23bd269434c1 100644 (file)
@@ -1,4 +1,4 @@
-/*     $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>
@@ -58,6 +59,8 @@ static char rcsid[] = "$NetBSD: crib.c,v 1.5 1995/03/21 15:08:42 cgd Exp $";
 #include "cribcur.h"
 #include "pathnames.h"
 
+int    main __P((int, char *[]));
+
 int
 main(argc, argv)
        int argc;
@@ -67,7 +70,7 @@ main(argc, argv)
        FILE *f;
        int ch;
 
-       while ((ch = getopt(argc, argv, "eqr")) != EOF)
+       while ((ch = getopt(argc, argv, "eqr")) != -1)
                switch (ch) {
                case 'e':
                        explain = TRUE;
@@ -126,17 +129,14 @@ main(argc, argv)
                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);
 }
 
@@ -193,10 +193,11 @@ gamescore()
 void
 game()
 {
-       register int i, j;
+       int i, j;
        BOOLEAN flag;
        BOOLEAN compcrib;
 
+       compcrib = FALSE;
        makedeck(deck);
        shuffle(deck);
        if (gamecount == 0) {
@@ -226,10 +227,13 @@ game()
                        } else
                                compcrib = (deck[i].rank > deck[j].rank);
                } while (flag);
+               do_wait();
                clear();
                makeboard();
                refresh();
        } else {
+               makeboard();
+               refresh();
                werase(Tablewin);
                wrefresh(Tablewin);
                werase(Compwin);
@@ -284,9 +288,12 @@ int
 playhand(mycrib)
        BOOLEAN mycrib;
 {
-       register int deckpos;
+       int deckpos;
 
        werase(Compwin);
+       wrefresh(Compwin);
+       werase(Tablewin);
+       wrefresh(Tablewin);
 
        knownum = 0;
        deckpos = deal(mycrib);
@@ -313,7 +320,7 @@ int
 deal(mycrib)
        BOOLEAN mycrib;
 {
-       register int i, j;
+       int i, j;
 
        for (i = j = 0; i < FULLHAND; i++) {
                if (mycrib) {
@@ -336,7 +343,7 @@ void
 discard(mycrib)
        BOOLEAN mycrib;
 {
-       register char *prompt;
+       char *prompt;
        CARD crd;
 
        prcrib(mycrib, TRUE);
@@ -367,7 +374,7 @@ cut(mycrib, pos)
        BOOLEAN mycrib;
        int  pos;
 {
-       register int i;
+       int i;
        BOOLEAN win;
 
        win = FALSE;
@@ -410,7 +417,7 @@ void
 prcrib(mycrib, blank)
        BOOLEAN mycrib, blank;
 {
-       register int y, cardx;
+       int y, cardx;
 
        if (mycrib)
                cardx = CRIB_X;
@@ -427,6 +434,7 @@ prcrib(mycrib, blank)
 
        for (y = CRIB_Y; y <= CRIB_Y + 5; y++)
                mvaddstr(y, cardx, "       ");
+       refresh();
 }
 
 /*
@@ -441,12 +449,13 @@ peg(mycrib)
        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];
@@ -473,6 +482,7 @@ peg(mycrib)
                                else {                  /* give him his point */
                                        msg(quiet ? "You get one" :
                                            "You get one point");
+                                       do_wait();
                                        if (chkscr(&pscore, 1))
                                                return TRUE;
                                        sum = 0;
@@ -550,6 +560,8 @@ peg(mycrib)
                                if (i > 0) {
                                        msg(quiet ? "You got %d" :
                                            "You got %d points", i);
+                                       if (pnum == 0)
+                                               do_wait();
                                        if (chkscr(&pscore, i))
                                                return TRUE;
                                }
@@ -580,6 +592,7 @@ peg(mycrib)
                } else {
                        msg(quiet ? "You get one for last" :
                            "You get one point for last");
+                       do_wait();
                        if (chkscr(&pscore, 1))
                                return TRUE;
                }
@@ -616,6 +629,7 @@ score(mycrib)
                do_wait();
                if (comphand(crib, "crib"))
                        return (TRUE);
+               do_wait();
        } else {
                if (comphand(chand, "hand"))
                        return (TRUE);