make scorehand know what really is a crib and how to deal with flushes
authorKen Arnold <arnold@ucbvax.Berkeley.EDU>
Wed, 7 Sep 1983 03:54:42 +0000 (19:54 -0800)
committerKen Arnold <arnold@ucbvax.Berkeley.EDU>
Wed, 7 Sep 1983 03:54:42 +0000 (19:54 -0800)
SCCS-vsn: games/cribbage/crib.c 1.17
SCCS-vsn: games/cribbage/io.c 1.12
SCCS-vsn: games/cribbage/support.c 1.14
SCCS-vsn: games/cribbage/score.c 1.4

usr/src/games/cribbage/crib.c
usr/src/games/cribbage/io.c
usr/src/games/cribbage/score.c
usr/src/games/cribbage/support.c

index eb68018..bc1db63 100644 (file)
@@ -1,4 +1,4 @@
-static char    *sccsid = "@(#)crib.c   1.16 (Berkeley) %G%";
+static char    *sccsid = "@(#)crib.c   1.17 (Berkeley) %G%";
 
 # include      <curses.h>
 # include      <signal.h>
 
 # include      <curses.h>
 # include      <signal.h>
@@ -98,20 +98,6 @@ char *argv[];
        bye();
 }
 
        bye();
 }
 
-/*
- * bye:
- *     Leave the program, cleaning things up as we go.
- */
-bye()
-{
-       signal(SIGINT, SIG_IGN);
-       mvcur(0, COLS - 1, LINES - 1, 0);
-       fflush(stdout);
-       endwin();
-       putchar('\n');
-       exit(1);
-}
-
 /*
  * makeboard:
  *     Print out the initial board on the screen
 /*
  * makeboard:
  *     Print out the initial board on the screen
index b806852..1ae3811 100644 (file)
@@ -1,7 +1,8 @@
-static char    *sccsid = "@(#)io.c     1.11 (Berkeley) %G%";
+static char    *sccsid = "@(#)io.c     1.12 (Berkeley) %G%";
 
 # include      <curses.h>
 # include      <ctype.h>
 
 # include      <curses.h>
 # include      <ctype.h>
+# include      <signal.h>
 # include      <unctrl.h>
 # include      "deck.h"
 # include      "cribbage.h"
 # include      <unctrl.h>
 # include      "deck.h"
 # include      "cribbage.h"
@@ -548,3 +549,17 @@ getline()
     stdscr = oscr;
     return linebuf;
 }
     stdscr = oscr;
     return linebuf;
 }
+
+/*
+ * bye:
+ *     Leave the program, cleaning things up as we go.
+ */
+bye()
+{
+       signal(SIGINT, SIG_IGN);
+       mvcur(0, COLS - 1, LINES - 1, 0);
+       fflush(stdout);
+       endwin();
+       putchar('\n');
+       exit(1);
+}
index d8c5b19..0841736 100644 (file)
@@ -1,4 +1,5 @@
-static char *sccsid = "@(#)score.c     1.3 (Berkeley) %G%";
+#
+static char *sccsid = "@(#)score.c     1.4 (Berkeley) %G%";
 
 #include       <stdio.h>
 #include       "deck.h"
 
 #include       <stdio.h>
 #include       "deck.h"
@@ -74,12 +75,12 @@ BOOLEAN                     do_explain;     /* true if must explain this hand */
        CARD                    h[(CINHAND + 1)];
        register int            i, k;
        register int            score;
        CARD                    h[(CINHAND + 1)];
        register int            i, k;
        register int            score;
-       BOOLEAN                 flag;
+       register BOOLEAN        flag;
        char                    buf[32];
 
        expl[0] = NULL;         /* initialize explanation */
        score = 0;
        char                    buf[32];
 
        expl[0] = NULL;         /* initialize explanation */
        score = 0;
-       flag = !crb;
+       flag = TRUE;
        k = hand[0].suit;
        for (i = 0; i < n; i++) {                       /* check for flush */
            flag = (flag && (hand[i].suit == k));
        k = hand[0].suit;
        for (i = 0; i < n; i++) {                       /* check for flush */
            flag = (flag && (hand[i].suit == k));
index f4114e9..9f894bd 100644 (file)
@@ -1,4 +1,4 @@
-static char    *sccsid = "@(#)support.c        1.13 (Berkeley) %G%";
+static char    *sccsid = "@(#)support.c        1.14 (Berkeley) %G%";
 
 #include       <curses.h>
 #include       "deck.h"
 
 #include       <curses.h>
 #include       "deck.h"
@@ -87,7 +87,7 @@ char          *s;
 
     prhand(hand, CINHAND, Playwin, FALSE);
     sprintf(prompt, "Your %s scores ", s);
 
     prhand(hand, CINHAND, Playwin, FALSE);
     sprintf(prompt, "Your %s scores ", s);
-    i = scorehand(hand, turnover, CINHAND, strcmp(s, "crib"), explain);
+    i = scorehand(hand, turnover, CINHAND, strcmp(s, "crib") == 0, explain);
     if ((j = number(0, 29, prompt)) == 19)
        j = 0;
     if (i != j) {
     if ((j = number(0, 29, prompt)) == 19)
        j = 0;
     if (i != j) {
@@ -120,7 +120,7 @@ char                *s;
 {
        register int            j;
 
 {
        register int            j;
 
-       j = scorehand(h, turnover, CINHAND, FALSE, FALSE);
+       j = scorehand(h, turnover, CINHAND, strcmp(s, "crib") == 0, FALSE);
        prhand(h, CINHAND, Compwin, FALSE);
        msg("My %s scores %d", s, (j == 0 ? 19 : j));
        return chkscr(&cscore, j);
        prhand(h, CINHAND, Compwin, FALSE);
        msg("My %s scores %d", s, (j == 0 ? 19 : j));
        return chkscr(&cscore, j);