159264Sbostic /*-
2*60777Sbostic * Copyright (c) 1980, 1993
3*60777Sbostic * The Regents of the University of California. All rights reserved.
433705Sbostic *
542575Sbostic * %sccs.include.redist.c%
621514Smckusick */
712571Sarnold
821514Smckusick #ifndef lint
9*60777Sbostic static char copyright[] =
10*60777Sbostic "@(#) Copyright (c) 1980, 1993\n\
11*60777Sbostic The Regents of the University of California. All rights reserved.\n";
1233705Sbostic #endif /* not lint */
1321514Smckusick
1421514Smckusick #ifndef lint
15*60777Sbostic static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 05/31/93";
1633705Sbostic #endif /* not lint */
1721514Smckusick
1859264Sbostic #include <curses.h>
1959264Sbostic #include <signal.h>
2059264Sbostic #include <stdlib.h>
2159264Sbostic #include <string.h>
2259264Sbostic #include <unistd.h>
237706Sarnold
2459264Sbostic #include "deck.h"
2559264Sbostic #include "cribbage.h"
2659264Sbostic #include "cribcur.h"
2759264Sbostic #include "pathnames.h"
2859264Sbostic
2959264Sbostic int
main(argc,argv)307871Sarnold main(argc, argv)
3159264Sbostic int argc;
3259264Sbostic char *argv[];
337706Sarnold {
3459264Sbostic BOOLEAN playing;
3559264Sbostic FILE *f;
3641186Sbostic int ch;
377706Sarnold
3841186Sbostic while ((ch = getopt(argc, argv, "eqr")) != EOF)
3959264Sbostic switch (ch) {
4041186Sbostic case 'e':
417706Sarnold explain = TRUE;
427706Sarnold break;
4341186Sbostic case 'q':
447706Sarnold quiet = TRUE;
457706Sarnold break;
4641186Sbostic case 'r':
477706Sarnold rflag = TRUE;
487706Sarnold break;
4941186Sbostic case '?':
5041186Sbostic default:
5141186Sbostic (void) fprintf(stderr, "usage: cribbage [-eqr]\n");
5241186Sbostic exit(1);
537706Sarnold }
547871Sarnold
557871Sarnold initscr();
5659264Sbostic (void)signal(SIGINT, rint);
577871Sarnold crmode();
587871Sarnold noecho();
5959264Sbostic
6012315Sarnold Playwin = subwin(stdscr, PLAY_Y, PLAY_X, 0, 0);
6112315Sarnold Tablewin = subwin(stdscr, TABLE_Y, TABLE_X, 0, PLAY_X);
6212315Sarnold Compwin = subwin(stdscr, COMP_Y, COMP_X, 0, TABLE_X + PLAY_X);
6312315Sarnold Msgwin = subwin(stdscr, MSG_Y, MSG_X, Y_MSG_START, SCORE_X + 1);
647871Sarnold leaveok(Playwin, TRUE);
657871Sarnold leaveok(Tablewin, TRUE);
667871Sarnold leaveok(Compwin, TRUE);
6712162Sarnold clearok(stdscr, FALSE);
687871Sarnold
697871Sarnold if (!quiet) {
7059264Sbostic msg("Do you need instructions for cribbage? ");
7159264Sbostic if (getuchar() == 'Y') {
7259264Sbostic endwin();
7359264Sbostic clear();
7459264Sbostic mvcur(0, COLS - 1, LINES - 1, 0);
7559264Sbostic fflush(stdout);
7659264Sbostic instructions();
7759264Sbostic crmode();
7859264Sbostic noecho();
7959264Sbostic clear();
8059264Sbostic refresh();
8159264Sbostic msg("For cribbage rules, use \"man cribbage\"");
8259264Sbostic }
837706Sarnold }
847706Sarnold playing = TRUE;
857871Sarnold do {
8659264Sbostic wclrtobot(Msgwin);
8759264Sbostic msg(quiet ? "L or S? " : "Long (to 121) or Short (to 61)? ");
8859264Sbostic if (glimit == SGAME)
8959264Sbostic glimit = (getuchar() == 'L' ? LGAME : SGAME);
9059264Sbostic else
9159264Sbostic glimit = (getuchar() == 'S' ? SGAME : LGAME);
9259264Sbostic game();
9359264Sbostic msg("Another game? ");
9459264Sbostic playing = (getuchar() == 'Y');
957871Sarnold } while (playing);
967871Sarnold
9741186Sbostic if (f = fopen(_PATH_LOG, "a")) {
9841186Sbostic (void)fprintf(f, "%s: won %5.5d, lost %5.5d\n",
9959264Sbostic getlogin(), cgames, pgames);
10059264Sbostic (void) fclose(f);
1017706Sarnold }
1027871Sarnold bye();
10341186Sbostic if (!f) {
10459264Sbostic (void) fprintf(stderr, "\ncribbage: can't open %s.\n",
10541186Sbostic _PATH_LOG);
10641186Sbostic exit(1);
10741186Sbostic }
10841186Sbostic exit(0);
1097706Sarnold }
1107706Sarnold
1117871Sarnold /*
1127871Sarnold * makeboard:
1137871Sarnold * Print out the initial board on the screen
1147871Sarnold */
11559264Sbostic void
makeboard()1167871Sarnold makeboard()
1177871Sarnold {
11859264Sbostic mvaddstr(SCORE_Y + 0, SCORE_X,
11959264Sbostic "+---------------------------------------+");
12059264Sbostic mvaddstr(SCORE_Y + 1, SCORE_X,
12159264Sbostic "| Score: 0 YOU |");
12259264Sbostic mvaddstr(SCORE_Y + 2, SCORE_X,
12359264Sbostic "| *.....:.....:.....:.....:.....:..... |");
12459264Sbostic mvaddstr(SCORE_Y + 3, SCORE_X,
12559264Sbostic "| *.....:.....:.....:.....:.....:..... |");
12659264Sbostic mvaddstr(SCORE_Y + 4, SCORE_X,
12759264Sbostic "| |");
12859264Sbostic mvaddstr(SCORE_Y + 5, SCORE_X,
12959264Sbostic "| *.....:.....:.....:.....:.....:..... |");
13059264Sbostic mvaddstr(SCORE_Y + 6, SCORE_X,
13159264Sbostic "| *.....:.....:.....:.....:.....:..... |");
13259264Sbostic mvaddstr(SCORE_Y + 7, SCORE_X,
13359264Sbostic "| Score: 0 ME |");
13459264Sbostic mvaddstr(SCORE_Y + 8, SCORE_X,
13559264Sbostic "+---------------------------------------+");
13659264Sbostic gamescore();
1377949Sarnold }
1387949Sarnold
1397949Sarnold /*
1407949Sarnold * gamescore:
1417949Sarnold * Print out the current game score
1427949Sarnold */
14359264Sbostic void
gamescore()1447949Sarnold gamescore()
1457949Sarnold {
14659264Sbostic extern int Lastscore[];
1477949Sarnold
14859264Sbostic if (pgames || cgames) {
14959264Sbostic mvprintw(SCORE_Y + 1, SCORE_X + 28, "Games: %3d", pgames);
15059264Sbostic mvprintw(SCORE_Y + 7, SCORE_X + 28, "Games: %3d", cgames);
15159264Sbostic }
15259264Sbostic Lastscore[0] = -1;
15359264Sbostic Lastscore[1] = -1;
1547871Sarnold }
1557871Sarnold
1567706Sarnold /*
1577871Sarnold * game:
1587933Sarnold * Play one game up to glimit points. Actually, we only ASK the
1597933Sarnold * player what card to turn. We do a random one, anyway.
1607706Sarnold */
16159264Sbostic void
game()1627706Sarnold game()
1637706Sarnold {
16459264Sbostic register int i, j;
16559264Sbostic BOOLEAN flag;
16659264Sbostic BOOLEAN compcrib;
1677706Sarnold
1687871Sarnold makedeck(deck);
1697871Sarnold shuffle(deck);
1707871Sarnold if (gamecount == 0) {
17159264Sbostic flag = TRUE;
17259264Sbostic do {
17359264Sbostic if (!rflag) { /* player cuts deck */
17459264Sbostic msg(quiet ? "Cut for crib? " :
17559264Sbostic "Cut to see whose crib it is -- low card wins? ");
17659264Sbostic getline();
17759264Sbostic }
17859264Sbostic i = (rand() >> 4) % CARDS; /* random cut */
17959264Sbostic do { /* comp cuts deck */
18059264Sbostic j = (rand() >> 4) % CARDS;
18159264Sbostic } while (j == i);
18259264Sbostic addmsg(quiet ? "You cut " : "You cut the ");
18359264Sbostic msgcard(deck[i], FALSE);
18459264Sbostic endmsg();
18559264Sbostic addmsg(quiet ? "I cut " : "I cut the ");
18659264Sbostic msgcard(deck[j], FALSE);
18759264Sbostic endmsg();
18859264Sbostic flag = (deck[i].rank == deck[j].rank);
18959264Sbostic if (flag) {
19059264Sbostic msg(quiet ? "We tied..." :
19159264Sbostic "We tied and have to try again...");
19259264Sbostic shuffle(deck);
19359264Sbostic continue;
19459264Sbostic } else
19559264Sbostic compcrib = (deck[i].rank > deck[j].rank);
19659264Sbostic } while (flag);
19759264Sbostic clear();
19859264Sbostic makeboard();
19959264Sbostic refresh();
20059264Sbostic } else {
20159264Sbostic werase(Tablewin);
20259264Sbostic wrefresh(Tablewin);
20359264Sbostic werase(Compwin);
20459264Sbostic wrefresh(Compwin);
20559264Sbostic msg("Loser (%s) gets first crib", (iwon ? "you" : "me"));
20659264Sbostic compcrib = !iwon;
2077706Sarnold }
2087871Sarnold
2097706Sarnold pscore = cscore = 0;
2107706Sarnold flag = TRUE;
2117871Sarnold do {
21259264Sbostic shuffle(deck);
21359264Sbostic flag = !playhand(compcrib);
21459264Sbostic compcrib = !compcrib;
2157871Sarnold } while (flag);
2167706Sarnold ++gamecount;
2177871Sarnold if (cscore < pscore) {
21859264Sbostic if (glimit - cscore > 60) {
21959264Sbostic msg("YOU DOUBLE SKUNKED ME!");
22059264Sbostic pgames += 4;
22159264Sbostic } else
22259264Sbostic if (glimit - cscore > 30) {
22359264Sbostic msg("YOU SKUNKED ME!");
22459264Sbostic pgames += 2;
22559264Sbostic } else {
22659264Sbostic msg("YOU WON!");
22759264Sbostic ++pgames;
22859264Sbostic }
22959264Sbostic iwon = FALSE;
23059264Sbostic } else {
23159264Sbostic if (glimit - pscore > 60) {
23259264Sbostic msg("I DOUBLE SKUNKED YOU!");
23359264Sbostic cgames += 4;
23459264Sbostic } else
23559264Sbostic if (glimit - pscore > 30) {
23659264Sbostic msg("I SKUNKED YOU!");
23759264Sbostic cgames += 2;
23859264Sbostic } else {
23959264Sbostic msg("I WON!");
24059264Sbostic ++cgames;
24159264Sbostic }
24259264Sbostic iwon = TRUE;
2437706Sarnold }
2447949Sarnold gamescore();
2457706Sarnold }
2467706Sarnold
2477706Sarnold /*
2487871Sarnold * playhand:
2497871Sarnold * Do up one hand of the game
2507706Sarnold */
25159264Sbostic int
playhand(mycrib)2527871Sarnold playhand(mycrib)
25359264Sbostic BOOLEAN mycrib;
2547871Sarnold {
25559264Sbostic register int deckpos;
2567706Sarnold
2577871Sarnold werase(Compwin);
2587706Sarnold
2597706Sarnold knownum = 0;
2607871Sarnold deckpos = deal(mycrib);
2617871Sarnold sorthand(chand, FULLHAND);
2627871Sarnold sorthand(phand, FULLHAND);
2637871Sarnold makeknown(chand, FULLHAND);
2648073Sarnold prhand(phand, FULLHAND, Playwin, FALSE);
2657871Sarnold discard(mycrib);
2667871Sarnold if (cut(mycrib, deckpos))
26759264Sbostic return TRUE;
2687871Sarnold if (peg(mycrib))
26959264Sbostic return TRUE;
2707871Sarnold werase(Tablewin);
2717871Sarnold wrefresh(Tablewin);
2727871Sarnold if (score(mycrib))
27359264Sbostic return TRUE;
2747871Sarnold return FALSE;
2757706Sarnold }
2767706Sarnold
2777706Sarnold /*
2787706Sarnold * deal cards to both players from deck
2797706Sarnold */
28059264Sbostic int
deal(mycrib)28159264Sbostic deal(mycrib)
28259264Sbostic BOOLEAN mycrib;
2837706Sarnold {
28459264Sbostic register int i, j;
2857706Sarnold
28659264Sbostic for (i = j = 0; i < FULLHAND; i++) {
28759264Sbostic if (mycrib) {
28859264Sbostic phand[i] = deck[j++];
28959264Sbostic chand[i] = deck[j++];
29059264Sbostic } else {
29159264Sbostic chand[i] = deck[j++];
29259264Sbostic phand[i] = deck[j++];
29359264Sbostic }
2947706Sarnold }
29559264Sbostic return (j);
2967706Sarnold }
2977706Sarnold
2987706Sarnold /*
2997871Sarnold * discard:
3007871Sarnold * Handle players discarding into the crib...
3017871Sarnold * Note: we call cdiscard() after prining first message so player doesn't wait
3027706Sarnold */
30359264Sbostic void
discard(mycrib)3047871Sarnold discard(mycrib)
30559264Sbostic BOOLEAN mycrib;
3067706Sarnold {
30759264Sbostic register char *prompt;
30859264Sbostic CARD crd;
3097706Sarnold
3107946Sarnold prcrib(mycrib, TRUE);
3117871Sarnold prompt = (quiet ? "Discard --> " : "Discard a card --> ");
31259264Sbostic cdiscard(mycrib); /* puts best discard at end */
3137871Sarnold crd = phand[infrom(phand, FULLHAND, prompt)];
31446743Sbostic cremove(crd, phand, FULLHAND);
3158073Sarnold prhand(phand, FULLHAND, Playwin, FALSE);
3167706Sarnold crib[0] = crd;
31759264Sbostic
31859264Sbostic /* Next four lines same as last four except for cdiscard(). */
3197871Sarnold crd = phand[infrom(phand, FULLHAND - 1, prompt)];
32046743Sbostic cremove(crd, phand, FULLHAND - 1);
3218073Sarnold prhand(phand, FULLHAND, Playwin, FALSE);
3227706Sarnold crib[1] = crd;
3237706Sarnold crib[2] = chand[4];
3247706Sarnold crib[3] = chand[5];
3257871Sarnold chand[4].rank = chand[4].suit = chand[5].rank = chand[5].suit = EMPTY;
3267706Sarnold }
3277706Sarnold
3287706Sarnold /*
3297871Sarnold * cut:
3307933Sarnold * Cut the deck and set turnover. Actually, we only ASK the
3317933Sarnold * player what card to turn. We do a random one, anyway.
3327706Sarnold */
33359264Sbostic int
cut(mycrib,pos)3347871Sarnold cut(mycrib, pos)
33559264Sbostic BOOLEAN mycrib;
33659264Sbostic int pos;
3377706Sarnold {
33859264Sbostic register int i;
33959264Sbostic BOOLEAN win;
3407706Sarnold
34159264Sbostic win = FALSE;
3427871Sarnold if (mycrib) {
34359264Sbostic if (!rflag) { /* random cut */
34459264Sbostic msg(quiet ? "Cut the deck? " :
34559264Sbostic "How many cards down do you wish to cut the deck? ");
34659264Sbostic getline();
34759264Sbostic }
34859264Sbostic i = (rand() >> 4) % (CARDS - pos);
34959264Sbostic turnover = deck[i + pos];
35059264Sbostic addmsg(quiet ? "You cut " : "You cut the ");
35159264Sbostic msgcard(turnover, FALSE);
35259264Sbostic endmsg();
35359264Sbostic if (turnover.rank == JACK) {
35459264Sbostic msg("I get two for his heels");
35559264Sbostic win = chkscr(&cscore, 2);
35659264Sbostic }
35759264Sbostic } else {
35859264Sbostic i = (rand() >> 4) % (CARDS - pos) + pos;
35959264Sbostic turnover = deck[i];
36059264Sbostic addmsg(quiet ? "I cut " : "I cut the ");
36159264Sbostic msgcard(turnover, FALSE);
36259264Sbostic endmsg();
36359264Sbostic if (turnover.rank == JACK) {
36459264Sbostic msg("You get two for his heels");
36559264Sbostic win = chkscr(&pscore, 2);
36659264Sbostic }
3677706Sarnold }
3687871Sarnold makeknown(&turnover, 1);
3697946Sarnold prcrib(mycrib, FALSE);
37059264Sbostic return (win);
3717706Sarnold }
3727706Sarnold
3737706Sarnold /*
3747946Sarnold * prcrib:
3757946Sarnold * Print out the turnover card with crib indicator
3767946Sarnold */
37759264Sbostic void
prcrib(mycrib,blank)3787946Sarnold prcrib(mycrib, blank)
37959264Sbostic BOOLEAN mycrib, blank;
3807946Sarnold {
38159264Sbostic register int y, cardx;
3827946Sarnold
3837946Sarnold if (mycrib)
38459264Sbostic cardx = CRIB_X;
3857946Sarnold else
38659264Sbostic cardx = 0;
3877946Sarnold
3887946Sarnold mvaddstr(CRIB_Y, cardx + 1, "CRIB");
3897946Sarnold prcard(stdscr, CRIB_Y + 1, cardx, turnover, blank);
39012162Sarnold
39112162Sarnold if (mycrib)
39259264Sbostic cardx = 0;
39312162Sarnold else
39459264Sbostic cardx = CRIB_X;
39512162Sarnold
39612162Sarnold for (y = CRIB_Y; y <= CRIB_Y + 5; y++)
39759264Sbostic mvaddstr(y, cardx, " ");
3987946Sarnold }
3997946Sarnold
4007946Sarnold /*
4017871Sarnold * peg:
4027871Sarnold * Handle all the pegging...
4037706Sarnold */
40459264Sbostic static CARD Table[14];
40559264Sbostic static int Tcnt;
4067706Sarnold
40759264Sbostic int
peg(mycrib)4087871Sarnold peg(mycrib)
40959264Sbostic BOOLEAN mycrib;
4107706Sarnold {
41159264Sbostic static CARD ch[CINHAND], ph[CINHAND];
41259264Sbostic register int i, j, k;
41359264Sbostic register int l;
41459264Sbostic register int cnum, pnum, sum;
41559264Sbostic register BOOLEAN myturn, mego, ugo, last, played;
41659264Sbostic CARD crd;
4177706Sarnold
4187706Sarnold cnum = pnum = CINHAND;
41959264Sbostic for (i = 0; i < CINHAND; i++) { /* make copies of hands */
42059264Sbostic ch[i] = chand[i];
42159264Sbostic ph[i] = phand[i];
4227706Sarnold }
42359264Sbostic Tcnt = 0; /* index to table of cards played */
42459264Sbostic sum = 0; /* sum of cards played */
4257706Sarnold mego = ugo = FALSE;
4267706Sarnold myturn = !mycrib;
4277871Sarnold for (;;) {
42859264Sbostic last = TRUE; /* enable last flag */
42959264Sbostic prhand(ph, pnum, Playwin, FALSE);
43059264Sbostic prhand(ch, cnum, Compwin, TRUE);
43159264Sbostic prtable(sum);
43259264Sbostic if (myturn) { /* my tyrn to play */
43359264Sbostic if (!anymove(ch, cnum, sum)) { /* if no card to play */
43459264Sbostic if (!mego && cnum) { /* go for comp? */
43559264Sbostic msg("GO");
43659264Sbostic mego = TRUE;
43759264Sbostic }
43859264Sbostic /* can player move? */
43959264Sbostic if (anymove(ph, pnum, sum))
44059264Sbostic myturn = !myturn;
44159264Sbostic else { /* give him his point */
44259264Sbostic msg(quiet ? "You get one" :
44359264Sbostic "You get one point");
44459264Sbostic if (chkscr(&pscore, 1))
44559264Sbostic return TRUE;
44659264Sbostic sum = 0;
44759264Sbostic mego = ugo = FALSE;
44859264Sbostic Tcnt = 0;
44959264Sbostic }
45059264Sbostic } else {
45159264Sbostic played = TRUE;
45259264Sbostic j = -1;
45359264Sbostic k = 0;
45459264Sbostic /* maximize score */
45559264Sbostic for (i = 0; i < cnum; i++) {
45659264Sbostic l = pegscore(ch[i], Table, Tcnt, sum);
45759264Sbostic if (l > k) {
45859264Sbostic k = l;
45959264Sbostic j = i;
46059264Sbostic }
46159264Sbostic }
46259264Sbostic if (j < 0) /* if nothing scores */
46359264Sbostic j = cchose(ch, cnum, sum);
46459264Sbostic crd = ch[j];
46559264Sbostic cremove(crd, ch, cnum--);
46659264Sbostic sum += VAL(crd.rank);
46759264Sbostic Table[Tcnt++] = crd;
46859264Sbostic if (k > 0) {
46959264Sbostic addmsg(quiet ? "I get %d playing " :
47059264Sbostic "I get %d points playing ", k);
47159264Sbostic msgcard(crd, FALSE);
47259264Sbostic endmsg();
47359264Sbostic if (chkscr(&cscore, k))
47459264Sbostic return TRUE;
47559264Sbostic }
47659264Sbostic myturn = !myturn;
4777706Sarnold }
47859264Sbostic } else {
47959264Sbostic if (!anymove(ph, pnum, sum)) { /* can player move? */
48059264Sbostic if (!ugo && pnum) { /* go for player */
48159264Sbostic msg("You have a GO");
48259264Sbostic ugo = TRUE;
48359264Sbostic }
48459264Sbostic /* can computer play? */
48559264Sbostic if (anymove(ch, cnum, sum))
48659264Sbostic myturn = !myturn;
48759264Sbostic else {
48859264Sbostic msg(quiet ? "I get one" :
48959264Sbostic "I get one point");
49059264Sbostic do_wait();
49159264Sbostic if (chkscr(&cscore, 1))
49259264Sbostic return TRUE;
49359264Sbostic sum = 0;
49459264Sbostic mego = ugo = FALSE;
49559264Sbostic Tcnt = 0;
49659264Sbostic }
49759264Sbostic } else { /* player plays */
49859264Sbostic played = FALSE;
49959264Sbostic if (pnum == 1) {
50059264Sbostic crd = ph[0];
50159264Sbostic msg("You play your last card");
50259264Sbostic } else
50359264Sbostic for (;;) {
50459264Sbostic prhand(ph,
50559264Sbostic pnum, Playwin, FALSE);
50659264Sbostic crd = ph[infrom(ph,
50759264Sbostic pnum, "Your play: ")];
50859264Sbostic if (sum + VAL(crd.rank) <= 31)
50959264Sbostic break;
51059264Sbostic else
51159264Sbostic msg("Total > 31 -- try again");
51259264Sbostic }
51359264Sbostic makeknown(&crd, 1);
51459264Sbostic cremove(crd, ph, pnum--);
51559264Sbostic i = pegscore(crd, Table, Tcnt, sum);
51659264Sbostic sum += VAL(crd.rank);
51759264Sbostic Table[Tcnt++] = crd;
51859264Sbostic if (i > 0) {
51959264Sbostic msg(quiet ? "You got %d" :
52059264Sbostic "You got %d points", i);
52159264Sbostic if (chkscr(&pscore, i))
52259264Sbostic return TRUE;
52359264Sbostic }
52459264Sbostic myturn = !myturn;
52559264Sbostic }
5267706Sarnold }
52759264Sbostic if (sum >= 31) {
52859264Sbostic if (!myturn)
52959264Sbostic do_wait();
5307706Sarnold sum = 0;
5317706Sarnold mego = ugo = FALSE;
5327871Sarnold Tcnt = 0;
53359264Sbostic last = FALSE; /* disable last flag */
5347706Sarnold }
53559264Sbostic if (!pnum && !cnum)
53659264Sbostic break; /* both done */
5377871Sarnold }
5388073Sarnold prhand(ph, pnum, Playwin, FALSE);
5398073Sarnold prhand(ch, cnum, Compwin, TRUE);
5408072Sarnold prtable(sum);
5417871Sarnold if (last)
54259264Sbostic if (played) {
54359264Sbostic msg(quiet ? "I get one for last" :
54459264Sbostic "I get one point for last");
54559264Sbostic do_wait();
54659264Sbostic if (chkscr(&cscore, 1))
54759264Sbostic return TRUE;
54859264Sbostic } else {
54959264Sbostic msg(quiet ? "You get one for last" :
5507871Sarnold "You get one point for last");
55159264Sbostic if (chkscr(&pscore, 1))
55259264Sbostic return TRUE;
55359264Sbostic }
55459264Sbostic return (FALSE);
5557706Sarnold }
5567706Sarnold
5577871Sarnold /*
5587871Sarnold * prtable:
5597871Sarnold * Print out the table with the current score
5607871Sarnold */
56159264Sbostic void
prtable(score)5627871Sarnold prtable(score)
56359264Sbostic int score;
5647871Sarnold {
5658073Sarnold prhand(Table, Tcnt, Tablewin, FALSE);
5667871Sarnold mvwprintw(Tablewin, (Tcnt + 2) * 2, Tcnt + 1, "%2d", score);
5677871Sarnold wrefresh(Tablewin);
5687871Sarnold }
5697706Sarnold
5707706Sarnold /*
5717871Sarnold * score:
5727871Sarnold * Handle the scoring of the hands
5737706Sarnold */
57459264Sbostic int
score(mycrib)5757871Sarnold score(mycrib)
57659264Sbostic BOOLEAN mycrib;
5777706Sarnold {
5787871Sarnold sorthand(crib, CINHAND);
5797871Sarnold if (mycrib) {
58059264Sbostic if (plyrhand(phand, "hand"))
58159264Sbostic return (TRUE);
58259264Sbostic if (comphand(chand, "hand"))
58359264Sbostic return (TRUE);
58459264Sbostic do_wait();
58559264Sbostic if (comphand(crib, "crib"))
58659264Sbostic return (TRUE);
58759264Sbostic } else {
58859264Sbostic if (comphand(chand, "hand"))
58959264Sbostic return (TRUE);
59059264Sbostic if (plyrhand(phand, "hand"))
59159264Sbostic return (TRUE);
59259264Sbostic if (plyrhand(crib, "crib"))
59359264Sbostic return (TRUE);
5947706Sarnold }
59559264Sbostic return (FALSE);
5967706Sarnold }
597