v11i034: vcraps - display-oriented craps game, Part01/02

0 views
Skip to first unread message

Bill Randle

unread,
Aug 23, 1990, 5:17:54 PM8/23/90
to
Submitted-by: Robert Steven Glickstein <bo...@andrew.cmu.edu>
Posting-number: Volume 11, Issue 34
Archive-name: vcraps/Part01

[[This is a public-domain full-screen casino-style craps game based on
curses, plus an interface-independent library providing craps-game
functionality. Included is a very simple Makefile. The interface
requires setjmp/longjmp, and uses index instead of strchr. It should be
pretty portable. Vcraps provides on-line help. See the README file for
more information.]]

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 1 (of 2)."
# Contents: README MANIFEST Makefile crapslib.h vcraps.c
# Wrapped by billr@saab on Thu Aug 23 14:15:44 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(3321 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X VCRAPS -- display-oriented casino craps
X CRAPSLIB -- interface-independent craps engine
X
XThis package contains crapslib and vcraps. Crapslib is an
Xinterface-independent craps-game library; vcraps is a curses-based
Xinterface built on top of crapslib.
X
XThe game is a full implementation of professional casino-style craps.
XVcraps provides on-line help in the form of the '?' key. For rules of
Xplay and betting, plus interesting strategies to minimize the "house
Xadvantage," please refer to Edwin Silberstang's excellent book,
X"Winning Casino Craps".
X
XThe "table" is a one-dollar table (i.e., all bets are in multiples of
X$1). By default, vcraps starts you off with a bankroll of $1,000 in a
Xcasino offering double free odds. The -b<bankroll> command-line
Xswitch can be used to start with a different bankroll. The -s switch
Xmeans use single free odds.
X
XVcraps input can be interrupted at any time with the escape key or
Xcontrol-L; the latter redraws the screen. Messages appear at the
Xbottom of the screen and must be cleared by pressing the spacebar.
X
XSome casinos pay different bets differently. Vcraps offers a single
Xconfiguration of payoffs, but other clients of crapslib can configure
Xthe payoffs that vary. (The varying payoffs are Big 6, Big 8, Field,
Xand the one-roll bets on 2, 3, 11, and 12.)
X
XThe bets and payoffs are as follows:
X
X
XPass-line 1-1.
XFree odds on pass-line 2-1 for 4 and 10,
X 3-2 for 5 and 9,
X 6-5 for 6 and 8.
XCome 1-1.
XFree odds on a come number 2-1 for 4 and 10,
X 3-2 for 5 and 9,
X 6-5 for 6 and 8.
XDon't pass (bar 12) 1-1.
XFree odds on don't pass 1-2 for 4 and 10,
X 2-3 for 5 and 9,
X 5-6 for 6 and 8.
XDon't come (bar 12) 1-1.
XFree odds on a don't come number 1-2 for 4 and 10,
X 2-3 for 5 and 9,
X 5-6 for 6 and 8.
XPlace numbers 9-5 for 4 and 10 (2-1 if bought),
X 7-5 for 5 and 9,
X 7-6 for 6 and 8.
X (Buying the 4 or 10 requires a 5% commission on the wager.)
X
XDon't place numbers 1-2 for 4 and 10,
X 2-3 for 5 and 9,
X 5-6 for 6 and 8.
X (Don't-place wagers require a 5% commission on the possible payoff.)
X
XBig 6 and Big 8 1-1
X (Some casinos pay 6-5.)
X
XField 1-1 for 3, 4, 9, 10, and 11,
X 2-1 for 2 and 12.
X (Some casinos pay 3-1 on either the 2 or the 12.)
X
XHardway bets 7-1 for 4 and 10,
X 9-1 for 6 and 8.
XOne-roll bets 29-1 for 2 and 12,
X 14-1 for 3 and 11.
X (Some casinos pay 30-1 and 15-1.)
X
XAny 7 4-1.
XAny Craps 7-1.
X
X
XAuthor: Bob Glickstein (bo...@andrew.cmu.edu) August 1990
XThis program is in the public domain.
END_OF_FILE
if test 3321 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(300 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X File Name Archive # Description
X-----------------------------------------------------------
X MANIFEST 1 This shipping list
X Makefile 1
X README 1
X crapslib.c 2
X crapslib.h 1
X vcraps.c 1
END_OF_FILE
if test 300 -ne `wc -c <'MANIFEST'`; then
echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(384 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
Xvcraps: crapslib.o vcraps.o
X cc -O -o vcraps vcraps.o crapslib.o -lcurses -ltermlib
X
Xvcraps.o: vcraps.c crapslib.h
X cc -O -I. -c vcraps.c
X
Xcrapslib.o: crapslib.c crapslib.h
X cc -O -I. -c crapslib.c
X
Xclean:
X -rm -f vcraps *.o *.a *~ *.BAK *.CKP core a.out mon.out gmon.out
X
Xshar:
X shar -n1 -e2 README Makefile crapslib.c crapslib.h > craps.1.shar
X shar -n2 -e2 vcraps.c > craps.2.shar
END_OF_FILE
if test 384 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'crapslib.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'crapslib.h'\"
else
echo shar: Extracting \"'crapslib.h'\" \(2970 characters\)
sed "s/^X//" >'crapslib.h' <<'END_OF_FILE'
Xtypedef enum {
X craps_PassLine, craps_PassLineOdds,
X craps_ComeBox, craps_Come4, craps_Come5, craps_Come6,
X craps_Come8, craps_Come9, craps_Come10,
X craps_ComeOdds4, craps_ComeOdds5, craps_ComeOdds6,
X craps_ComeOdds8, craps_ComeOdds9, craps_ComeOdds10,
X craps_DontPass, craps_DontPassOdds,
X craps_DontComeBox, craps_DontCome4, craps_DontCome5,
X craps_DontCome6, craps_DontCome8, craps_DontCome9,
X craps_DontCome10,
X craps_DontComeOdds4, craps_DontComeOdds5, craps_DontComeOdds6,
X craps_DontComeOdds8, craps_DontComeOdds9, craps_DontComeOdds10,
X craps_Place4, craps_Place5, craps_Place6, craps_Place8,
X craps_Place9, craps_Place10,
X craps_DontPlace4, craps_DontPlace5, craps_DontPlace6,
X craps_DontPlace8, craps_DontPlace9, craps_DontPlace10,
X craps_Field, craps_Big6, craps_Big8,
X craps_Hard4, craps_Hard6, craps_Hard8, craps_Hard10,
X craps_Any7, craps_AnyCraps,
X craps_OneRoll2, craps_OneRoll3, craps_OneRoll11, craps_OneRoll12,
X craps_Bets
X} CrapsBet_t;
X
Xtypedef enum {
X crapserr_OK,
X crapserr_NoReturn,
X crapserr_AlreadyBought,
X crapserr_Nonpositive,
X crapserr_NoBet,
X crapserr_InsufficientFunds,
X crapserr_NotComeOut,
X crapserr_ComeOut,
X crapserr_TooMuch,
X crapserr_NotDivisible
X} CrapsError_t;
X
Xtypedef struct {
X int numerator, denominator;
X} CrapsPayoff_t;
X
Xtypedef struct {
X int bankroll, point, die1, die2;
X int bought4, bought10; /* booleans */
X /* Configuration: */
X int doublep;
X CrapsPayoff_t field2payoff, field12payoff, big6payoff;
X CrapsPayoff_t big8payoff, oneroll2payoff, oneroll3payoff;
X CrapsPayoff_t oneroll11payoff, oneroll12payoff;
X /* Bets: */
X int bets[craps_Bets];
X} CrapsTable_t;
X
X#define Craps_Bankroll(t) ((t)->bankroll)
X#define Craps_Point(t) ((t)->point)
X#define Craps_Die1(t) ((t)->die1)
X#define Craps_Die2(t) ((t)->die2)
X#define Craps_Bought4(t) ((t)->bought4)
X#define Craps_Bought10(t) ((t)->bought10)
X#define Craps_Doublep(t) ((t)->doublep)
X#define Craps_Field2Payoff(t) (&((t)->field2payoff))
X#define Craps_Field12Payoff(t) (&((t)->field12payoff))
X#define Craps_Big6Payoff(t) (&((t)->big6payoff))
X#define Craps_Big8Payoff(t) (&((t)->big8payoff))
X#define Craps_OneRoll2Payoff(t) (&((t)->oneroll2payoff))
X#define Craps_OneRoll3Payoff(t) (&((t)->oneroll3payoff))
X#define Craps_OneRoll11Payoff(t) (&((t)->oneroll11payoff))
X#define Craps_OneRoll12Payoff(t) (&((t)->oneroll12payoff))
X#define Craps_GetBet(t,type) ((t)->bets[(type)])
X
X#define Craps_SetBankroll(t,b) (((t)->bankroll)=(b))
X#define Craps_SetDouble(t,d) (((t)->doublep)=(d))
X
X#define Craps_IncrBankroll(t,amt) (((t)->bankroll)+=(amt))
X
Xextern CrapsError_t Craps_Bet();
Xextern CrapsError_t Craps_Buy();
Xextern void Craps_GetPayoff();
Xextern void Craps_Init();
Xextern CrapsError_t Craps_TakeDown();
Xextern void Craps_Update();
END_OF_FILE
if test 2970 -ne `wc -c <'crapslib.h'`; then
echo shar: \"'crapslib.h'\" unpacked with wrong size!
fi
# end of 'crapslib.h'
fi
if test -f 'vcraps.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vcraps.c'\"
else
echo shar: Extracting \"'vcraps.c'\" \(43812 characters\)
sed "s/^X//" >'vcraps.c' <<'END_OF_FILE'
X#include <crapslib.h>
X#include <curses.h>
X#include <setjmp.h>
X
Xextern int CrapsErrorDatum;
Xextern int optind;
Xextern char *optarg;
X
Xjmp_buf LoopEnv;
X
XWINDOW *dontplace4win, *dontplace5win, *dontplace6win, *dontplace8win;
XWINDOW *dontplace9win, *dontplace10win;
XWINDOW *dontcome4win, *dontcome5win, *dontcome6win, *dontcome8win;
XWINDOW *dontcome9win, *dontcome10win;
XWINDOW *place4win, *place5win, *place6win, *place8win, *place9win;
XWINDOW *place10win;
XWINDOW *come4win, *come5win, *come6win, *come8win, *come9win;
XWINDOW *come10win;
XWINDOW *bankrollwin, *pointwin, *passlinewin, *comewin;
XWINDOW *dontpasswin, *dontcomewin, *fieldwin, *big6win, *big8win;
XWINDOW *hard4win, *hard6win, *hard8win, *hard10win;
XWINDOW *oneroll2win, *oneroll3win, *oneroll11win, *oneroll12win;
XWINDOW *any7win, *anycrapswin;
XWINDOW *dicewin;
XWINDOW *promptwin, *commandwin, *msgwin;
X
Xchar *BetName[] = {
X "Pass Line", "Pass Line Odds",
X "Come",
X "Come 4", "Come 5", "Come 6", "Come 8", "Come 9", "Come 10",
X "Come 4 Odds", "Come 5 Odds", "Come 6 Odds", "Come 8 Odds",
X "Come 9 Odds", "Come 10 Odds",
X "Don't Pass", "Don't Pass Odds",
X "Don't Come",
X "Don't Come 4", "Don't Come 5", "Don't Come 6",
X "Don't Come 8", "Don't Come 9", "Don't Come 10",
X "Don't Come 4 Odds", "Don't Come 5 Odds", "Don't Come 6 Odds",
X "Don't Come 8 Odds", "Don't Come 9 Odds", "Don't Come 10 Odds",
X "Place 4", "Place 5", "Place 6", "Place 8", "Place 9", "Place 10",
X "Don't Place 4", "Don't Place 5", "Don't Place 6",
X "Don't Place 8", "Don't Place 9", "Don't Place 10",
X "Field", "Big 6", "Big 8", "Hard 4", "Hard 6",
X "Hard 8", "Hard 10", "Any 7", "Any Craps",
X "One-Roll 2", "One-Roll 3", "One-Roll 11", "One-Roll 12"
X};
X
XCrapsTable_t Table, OldTable;
X
Xinit()
X{
X initscr();
X cbreak();
X noecho();
X dontplace4win = newwin(1, 9, 1, 13);
X dontplace5win = newwin(1, 9, 1, 24);
X dontplace6win = newwin(1, 9, 1, 35);
X dontplace8win = newwin(1, 9, 1, 46);
X dontplace9win = newwin(1, 9, 1, 57);
X dontplace10win = newwin(1, 9, 1, 68);
X dontcome4win = newwin(1, 9, 2, 13);
X dontcome5win = newwin(1, 9, 2, 24);
X dontcome6win = newwin(1, 9, 2, 35);
X dontcome8win = newwin(1, 9, 2, 46);
X dontcome9win = newwin(1, 9, 2, 57);
X dontcome10win = newwin(1, 9, 2, 68);
X place4win = newwin(1, 9, 3, 13);
X place5win = newwin(1, 9, 3, 24);
X place6win = newwin(1, 9, 3, 35);
X place8win = newwin(1, 9, 3, 46);
X place9win = newwin(1, 9, 3, 57);
X place10win = newwin(1, 9, 3, 68);
X come4win = newwin(1, 9, 4, 13);
X come5win = newwin(1, 9, 4, 24);
X come6win = newwin(1, 9, 4, 35);
X come8win = newwin(1, 9, 4, 46);
X come9win = newwin(1, 9, 4, 57);
X come10win = newwin(1, 9, 4, 68);
X bankrollwin = newwin(1, 14, 7, 0);
X pointwin = newwin(1, 11, 7, 16);
X passlinewin = newwin(1, 19, 7, 31);
X comewin = newwin(1, 14, 7, 52);
X dontpasswin = newwin(1, 16, 10, 0);
X dontcomewin = newwin(1, 16, 10, 18);
X fieldwin = newwin(1, 11, 10, 38);
X big6win = newwin(1, 11, 10, 53);
X big8win = newwin(1, 11, 10, 66);
X hard4win = newwin(1, 9, 16, 0);
X hard6win = newwin(1, 9, 13, 0);
X hard8win = newwin(1, 9, 13, 11);
X hard10win = newwin(1, 9, 16, 11);
X oneroll2win = newwin(1, 9, 13, 24);
X oneroll3win = newwin(1, 9, 16, 24);
X oneroll11win = newwin(1, 9, 16, 35);
X oneroll12win = newwin(1, 9, 13, 35);
X any7win = newwin(1, 15, 13, 48);
X anycrapswin = newwin(1, 15, 16, 48);
X dicewin = newwin(1, 4, 20, 0);
X promptwin = newwin(1, 70, 19, 6);
X commandwin = newwin(1, 70, 20, 6);
X msgwin = newwin(1, 78, 22, 0);
X Craps_Init(&Table);
X srandom(time(0) + getpid());
X}
X
Xvoid wcenter(win, str, line, highlightp)
XWINDOW *win;
Xchar *str;
Xint line, highlightp;
X{
X wmove(win, line, 0);
X wclrtoeol(win);
X wmove(win, line, (int) ((win->_maxx - strlen(str)) / 2));
X if (highlightp)
X wstandout(win);
X waddstr(win, str);
X if (highlightp)
X wstandend(win);
X}
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X int c;
X
X init();
X Craps_SetBankroll(&Table, 1000);
X while ((c = getopt(argc, argv, "b:sx")) != EOF) {
X switch (c) {
X case 'b':
X Craps_SetBankroll(&Table, atoi(optarg));
X break;
X case 's':
X Craps_SetDouble(&Table, 0);
X break;
X default:
X deinit();
X fprintf(stderr, "Usage: vcraps [-b bankroll] [-s]\n");
X exit(1);
X }
X }
X Driver();
X deinit();
X exit(0);
X}
X
XDriver()
X{
X int c, amount, fullupdate = 1, jmpval, die1, die2, i;
X char buf[20];
X CrapsError_t err;
X CrapsTable_t *t = &Table;
X
X if ((jmpval = setjmp(LoopEnv)) == 1)
X Message("ABORTED");
X if (jmpval == 2)
X fullupdate = 1;
X while (1) {
X Update(fullupdate);
X bcopy(&Table, &OldTable, (sizeof(CrapsTable_t)));
X fullupdate = 0;
X Prompt("Command [12345689abcdfhprtX?]:");
X wclear(commandwin);
X wrefresh(commandwin);
X c = Getch("12345689abcdfhprtX?", 1);
X switch (c) {
X case '1':
X Prompt("[012]:");
X c = Getch("012", 1);
X switch (c) {
X case '0':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for come-odds on 10:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_ComeOdds10,
X amount))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for don't-come odds on 10:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table,
X craps_DontComeOdds10,
X amount))
X Error(err);
X break;
X case 'p':
X Prompt("Amount for don't-pass bet on 10:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table,
X craps_DontPlace10,
X amount))
X Error(err);
X break;
X }
X break;
X case 'p':
X Prompt("Amount for place bet on 10:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Place10, amount))
X Error(err);
X }
X break;
X case '1':
X Prompt("Amount for one-roll bet on 11:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_OneRoll11, amount))
X Error(err);
X break;
X case '2':
X Prompt("Amount for one-roll bet on 12:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_OneRoll12, amount))
X Error(err);
X break;
X }
X break;
X case '2':
X Prompt("Amount for one-roll bet on 2:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_OneRoll2, amount))
X Error(err);
X break;
X case '3':
X Prompt("Amount for one-roll bet on 3:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_OneRoll3, amount))
X Error(err);
X break;
X case '4':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for come-odds on 4:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_ComeOdds4, amount))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for don't-come odds on 4:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontComeOdds4,
X amount))
X Error(err);
X break;
X case 'p':
X Prompt("Amount for don't-pass bet on 4:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontPlace4,
X amount))
X Error(err);
X break;
X }
X break;
X case 'p':
X Prompt("Amount for place bet on 4:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Place4, amount))
X Error(err);
X break;
X }
X break;
X case '5':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for come-odds on 5:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_ComeOdds5, amount))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for don't-come odds on 5:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontComeOdds5,
X amount))
X Error(err);
X break;
X case 'p':
X Prompt("Amount for don't-pass bet on 5:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontPlace5,
X amount))
X Error(err);
X break;
X }
X break;
X case 'p':
X Prompt("Amount for place bet on 5:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Place5, amount))
X Error(err);
X break;
X }
X break;
X case '6':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for come-odds on 6:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_ComeOdds6, amount))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for don't-come odds on 6:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontComeOdds6,
X amount))
X Error(err);
X break;
X case 'p':
X Prompt("Amount for don't-pass bet on 6:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontPlace6,
X amount))
X Error(err);
X break;
X }
X break;
X case 'p':
X Prompt("Amount for place bet on 6:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Place6, amount))
X Error(err);
X break;
X }
X break;
X case '8':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for come-odds on 8:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_ComeOdds8, amount))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for don't-come odds on 8:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontComeOdds8,
X amount))
X Error(err);
X break;
X case 'p':
X Prompt("Amount for don't-pass bet on 8:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontPlace8,
X amount))
X Error(err);
X break;
X }
X break;
X case 'p':
X Prompt("Amount for place bet on 8:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Place8, amount))
X Error(err);
X break;
X }
X break;
X case '9':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for come-odds on 9:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_ComeOdds9, amount))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for don't-come odds on 9:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontComeOdds9,
X amount))
X Error(err);
X break;
X case 'p':
X Prompt("Amount for don't-pass bet on 9:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontPlace9,
X amount))
X Error(err);
X break;
X }
X break;
X case 'p':
X Prompt("Amount for place bet on 9:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Place9, amount))
X Error(err);
X break;
X }
X break;
X case 'a':
X Prompt("[7c]:");
X c = Getch("7c", 1);
X switch (c) {
X case '7':
X Prompt("Amount for bet on Any 7:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Any7, amount))
X Error(err);
X break;
X case 'c':
X Prompt("Amount for bet on Any Craps:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_AnyCraps, amount))
X Error(err);
X break;
X }
X break;
X case 'b':
X Prompt("[1468]:");
X c = Getch("1468", 1);
X switch (c) {
X case '1':
X Prompt("[0]:");
X Getch("0", 1);
X if (err = Craps_Buy(t, 10))
X Error(err);
X break;
X case '4':
X if (err = Craps_Buy(t, 4))
X Error(err);
X break;
X case '6':
X Prompt("Amount for bet on Big 6:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Big6, amount))
X Error(err);
X break;
X case '8':
X Prompt("Amount for bet on Big 8:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Big8, amount))
X Error(err);
X break;
X }
X break;
X case 'c':
X Prompt("Amount for bet on Come:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_ComeBox, amount))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X Prompt("Amount for bet on Don't Come:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontComeBox, amount))
X Error(err);
X break;
X case 'p':
X if (Craps_Point(&Table)) {
X Prompt("Amount for odds on Don't Pass:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontPassOdds, amount))
X Error(err);
X }
X else {
X Prompt("Amount for bet on Don't Pass:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_DontPass, amount))
X Error(err);
X }
X break;
X }
X break;
X case 'f':
X Prompt("Amount for bet on Field:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Field, amount))
X Error(err);
X break;
X case 'h':
X Prompt("[2345]:");
X c = Getch("2345", 1);
X switch (c) {
X case '2':
X Prompt("[2]:");
X Getch("2", 1);
X Prompt("Amount for bet on Hard 4:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Hard4, amount))
X Error(err);
X break;
X case '3':
X Prompt("[3]:");
X Getch("3", 1);
X Prompt("Amount for bet on Hard 6:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Hard6, amount))
X Error(err);
X break;
X case '4':
X Prompt("[4]:");
X Getch("4", 1);
X Prompt("Amount for bet on Hard 8:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Hard8, amount))
X Error(err);
X break;
X case '5':
X Prompt("[5]:");
X Getch("5", 1);
X Prompt("Amount for bet on Hard 10:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_Hard10, amount))
X Error(err);
X break;
X }
X break;
X case 'p':
X if (Craps_Point(&Table)) {
X Prompt("Amount for odds on Pass Line:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_PassLineOdds, amount))
X Error(err);
X }
X else {
X Prompt("Amount for bet on Pass Line:");
X amount = ReadNumber();
X if (err = Craps_Bet(&Table, craps_PassLine, amount))
X Error(err);
X }
X break;
X case 'r':
X Prompt("ROLL");
X for (i = (random() % 40) + 40; i >= 0; --i) {
X die1 = 1 + (random() % 6);
X die2 = 1 + (random() % 6);
X sprintf(buf, "%d %d", die1, die2);
X wcenter(dicewin, buf, 0, 1);
X wrefresh(dicewin);
X }
X Craps_Update(&Table, die1, die2);
X break;
X case 't':
X Prompt("[12345689abcdfhp]:");
X c = Getch("12345689abcdfhp", 1);
X switch (c) {
X case '1':
X Prompt("[012]:");
X c = Getch("012", 1);
X switch (c) {
X case '0':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t,
X craps_ComeOdds10))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t,
X craps_DontComeOdds10))
X Error(err);
X break;
X case 'p':
X if (err = Craps_TakeDown(t,
X craps_DontPlace10))
X Error(err);
X break;
X }
X break;
X case 'p':
X if (err = Craps_TakeDown(t, craps_Place10))
X Error(err);
X break;
X }
X break;
X case '1':
X if (err = Craps_TakeDown(t, craps_OneRoll11))
X Error(err);
X break;
X case '2':
X if (err = Craps_TakeDown(t, craps_OneRoll12))
X Error(err);
X break;
X }
X break;
X case '2':
X if (err = Craps_TakeDown(t, craps_OneRoll2))
X Error(err);
X break;
X case '3':
X if (err = Craps_TakeDown(t, craps_OneRoll3))
X Error(err);
X break;
X case '4':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t, craps_ComeOdds4))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t,
X craps_DontComeOdds4))
X Error(err);
X break;
X case 'p':
X if (err = Craps_TakeDown(t,
X craps_DontPlace4))
X Error(err);
X break;
X }
X break;
X case 'p':
X if (err = Craps_TakeDown(t, craps_Place4))
X Error(err);
X break;
X }
X break;
X case '5':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t, craps_ComeOdds5))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t,
X craps_DontComeOdds5))
X Error(err);
X break;
X case 'p':
X if (err = Craps_TakeDown(t,
X craps_DontPlace5))
X Error(err);
X break;
X }
X break;
X case 'p':
X if (err = Craps_TakeDown(t, craps_Place5))
X Error(err);
X break;
X }
X break;
X case '6':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t, craps_ComeOdds6))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t,
X craps_DontComeOdds6))
X Error(err);
X break;
X case 'p':
X if (err = Craps_TakeDown(t,
X craps_DontPlace6))
X Error(err);
X break;
X }
X break;
X case 'p':
X if (err = Craps_TakeDown(t, craps_Place6))
X Error(err);
X break;
X }
X break;
X case '8':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t, craps_ComeOdds8))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t,
X craps_DontComeOdds8))
X Error(err);
X break;
X case 'p':
X if (err = Craps_TakeDown(t,
X craps_DontPlace8))
X Error(err);
X break;
X }
X break;
X case 'p':
X if (err = Craps_TakeDown(t, craps_Place8))
X Error(err);
X break;
X }
X break;
X case '9':
X Prompt("[cdp]:");
X c = Getch("cdp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t, craps_ComeOdds9))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t,
X craps_DontComeOdds9))
X Error(err);
X break;
X case 'p':
X if (err = Craps_TakeDown(t,
X craps_DontPlace9))
X Error(err);
X break;
X }
X break;
X case 'p':
X if (err = Craps_TakeDown(t, craps_Place9))
X Error(err);
X break;
X }
X break;
X case 'a':
X Prompt("[7c]:");
X c = Getch("7c", 1);
X switch (c) {
X case '7':
X if (err = Craps_TakeDown(t, craps_Any7))
X Error(err);
X break;
X case 'c':
X if (err = Craps_TakeDown(t, craps_AnyCraps))
X Error(err);
X break;
X }
X break;
X case 'b':
X Prompt("[68]:");
X c = Getch("68", 1);
X switch (c) {
X case '6':
X if (err = Craps_TakeDown(t, craps_Big6))
X Error(err);
X break;
X case '8':
X if (err = Craps_TakeDown(t, craps_Big8))
X Error(err);
X break;
X }
X break;
X case 'c':
X if (err = Craps_TakeDown(t, craps_ComeBox))
X Error(err);
X break;
X case 'd':
X Prompt("[cp]:");
X c = Getch("cp", 1);
X switch (c) {
X case 'c':
X if (err = Craps_TakeDown(t, craps_DontComeBox))
X Error(err);
X break;
X case 'p':
X if (err = Craps_TakeDown(t,
X Craps_Point(t) ?
X craps_DontPassOdds :
X craps_DontPass))
X Error(err);
X break;
X }
X break;
X case 'f':
X if (err = Craps_TakeDown(t, craps_Field))
X Error(err);
X break;
X case 'h':
X Prompt("[2345]:");
X c = Getch("2345", 1);
X switch (c) {
X case '2':
X Prompt("[2]:");
X Getch("2", 1);
X if (err = Craps_TakeDown(t, craps_Hard4))
X Error(err);
X break;
X case '3':
X Prompt("[3]:");
X Getch("3", 1);
X if (err = Craps_TakeDown(t, craps_Hard6))
X Error(err);
X break;
X case '4':
X Prompt("[4]:");
X Getch("4", 1);
X if (err = Craps_TakeDown(t, craps_Hard8))
X Error(err);
X break;
X case '5':
X Prompt("[5]:");
X Getch("5", 1);
X if (err = Craps_TakeDown(t, craps_Hard10))
X Error(err);
X break;
X }
X break;
X case 'p':
X if (err = Craps_TakeDown(t,
X Craps_Point(t) ?
X craps_PassLineOdds :
X craps_PassLine))
X Error(err);
X break;
X }
X break;
X case 'X':
X return (0);
X case '?':
X Help();
X break;
X }
X }
X}
X
XMessage(str)
Xchar *str;
X{
X wcenter(msgwin, str, 0, 0);
X wrefresh(msgwin);
X while (wgetch(msgwin) != ' ');
X wclear(msgwin);
X wrefresh(msgwin);
X}
X
XPrompt(str)
Xchar *str;
X{
X wclear(promptwin);
X wmove(promptwin, 0, 0);
X waddstr(promptwin, str);
X wrefresh(promptwin);
X}
X
Xint Getch(key, echop)
Xchar *key;
Xint echop;
X{
X int c;
X
X do {
X c = wgetch(commandwin);
X if (c == 27)
X longjmp(LoopEnv, 1);
X if (c == 12)
X longjmp(LoopEnv, 2);
X if ((c == 127) && index(key, '\b'))
X break;
X } while (!index(key, c));
X if (echop) {
X waddch(commandwin, c);
X wrefresh(commandwin);
X }
X return (c);
X}
X
Xdeinit()
X{
X clear();
X refresh();
X endwin();
X}
X
Xvoid Craps_ReportPayoff(t, bet, payoff, win)
XCrapsTable_t *t;
XCrapsBet_t bet;
XCrapsPayoff_t *payoff;
Xint win;
X{
X char buf[100];
X
X sprintf(buf, "Casino pays $%d %s bet at %d-%d; you collect $%d",
X Craps_GetBet(t, bet), BetName[bet], payoff->numerator,
X payoff->denominator, win + Craps_GetBet(t, bet));
X Message(buf);
X}
X
Xvoid Craps_ReportCollect(t, bet)
XCrapsTable_t *t;
XCrapsBet_t bet;
X{
X}
X
Xvoid Craps_ReportReturn(t, bet)
XCrapsTable_t *t;
XCrapsBet_t bet;
X{
X char buf[100];
X
X sprintf(buf, "Casino returns $%d %s bet",
X Craps_GetBet(t, bet), BetName[bet]);
X Message(buf);
X}
X
Xvoid Craps_ReportCommission(t, amount)
XCrapsTable_t *t;
Xint amount;
X{
X char buf[100];
X
X sprintf(buf, "Casino takes $%d commission", amount);
X Message(buf);
X}
X
Xvoid Craps_ReportMove(t, from, to)
XCrapsTable_t *t;
XCrapsBet_t from, to;
X{
X}
X
XUpdate(full)
Xint full;
X{
X char buf[80];
X int num;
X
X if (full) {
X clear();
X move(0, 0);
X addstr(" ----4---- ----5---- ----6---- ----8---- ----9---- ---10----");
X move(1, 0);
X addstr("DON'T PLACE");
X move(2, 0);
X addstr(" DON'T COME");
X move(3, 0);
X addstr(" PLACE");
X move(4, 0);
X addstr(" COME");
X move(6, 0);
X addstr("---Bankroll--- ---Point--- -----Pass Line----- -----Come-----");
X move(9, 0);
X addstr("---Don't Pass--- ---Don't Come--- ---Field--- ---Big 6--- ---Big 8---");
X move(12, 0);
X addstr("---3-3--- ---4-4--- ---1-1--- ---6-6--- ---Any Seven---");
X move(15, 0);
X addstr("---2-2--- ---5-5--- ---1-2--- ---5-6--- ---Any Craps---");
X move(18, 0);
X addstr("=============================================================================");
X move(19, 0);
X addstr("DICE");
X move(21, 0);
X addstr("=============================================================================");
X refresh();
X }
X if (full || (Craps_GetBet(&Table, craps_DontPlace4) != Craps_GetBet(&OldTable, craps_DontPlace4))) {
X if (num = Craps_GetBet(&Table, craps_DontPlace4)) {
X sprintf(buf, " %d ", num);
X wcenter(dontplace4win, buf, 0, 1);
X }
X else {
X wclear(dontplace4win);
X }
X wrefresh(dontplace4win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontPlace5) !=
X Craps_GetBet(&OldTable, craps_DontPlace5))) {
X if (num = Craps_GetBet(&Table, craps_DontPlace5)) {
X sprintf(buf, " %d ", num);
X wcenter(dontplace5win, buf, 0, 1);
X }
X else {
X wclear(dontplace5win);
X }
X wrefresh(dontplace5win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontPlace6) !=
X Craps_GetBet(&OldTable, craps_DontPlace6))) {
X if (num = Craps_GetBet(&Table, craps_DontPlace6)) {
X sprintf(buf, " %d ", num);
X wcenter(dontplace6win, buf, 0, 1);
X }
X else {
X wclear(dontplace6win);
X }
X wrefresh(dontplace6win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontPlace8) !=
X Craps_GetBet(&OldTable, craps_DontPlace8))) {
X if (num = Craps_GetBet(&Table, craps_DontPlace8)) {
X sprintf(buf, " %d ", num);
X wcenter(dontplace8win, buf, 0, 1);
X }
X else {
X wclear(dontplace8win);
X }
X wrefresh(dontplace8win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontPlace9) !=
X Craps_GetBet(&OldTable, craps_DontPlace9))) {
X if (num = Craps_GetBet(&Table, craps_DontPlace9)) {
X sprintf(buf, " %d ", num);
X wcenter(dontplace9win, buf, 0, 1);
X }
X else {
X wclear(dontplace9win);
X }
X wrefresh(dontplace9win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontPlace10) !=
X Craps_GetBet(&OldTable, craps_DontPlace10))) {
X if (num = Craps_GetBet(&Table, craps_DontPlace10)) {
X sprintf(buf, " %d ", num);
X wcenter(dontplace10win, buf, 0, 1);
X }
X else {
X wclear(dontplace10win);
X }
X wrefresh(dontplace10win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontCome4) !=
X Craps_GetBet(&OldTable, craps_DontCome4)) ||
X (Craps_GetBet(&Table, craps_DontComeOdds4) !=
X Craps_GetBet(&OldTable, craps_DontComeOdds4))) {
X if (num = Craps_GetBet(&Table, craps_DontCome4)) {
X if (Craps_GetBet(&Table, craps_DontComeOdds4))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_DontComeOdds4));
X else
X sprintf(buf, " %d ", num);
X wcenter(dontcome4win, buf, 0, 1);
X }
X else {
X wclear(dontcome4win);
X }
X wrefresh(dontcome4win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontCome5) !=
X Craps_GetBet(&OldTable, craps_DontCome5)) ||
X (Craps_GetBet(&Table, craps_DontComeOdds5) !=
X Craps_GetBet(&OldTable, craps_DontComeOdds5))) {
X if (num = Craps_GetBet(&Table, craps_DontCome5)) {
X if (Craps_GetBet(&Table, craps_DontComeOdds5))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_DontComeOdds5));
X else
X sprintf(buf, " %d ", num);
X wcenter(dontcome5win, buf, 0, 1);
X }
X else {
X wclear(dontcome5win);
X }
X wrefresh(dontcome5win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontCome6) !=
X Craps_GetBet(&OldTable, craps_DontCome6)) ||
X (Craps_GetBet(&Table, craps_DontComeOdds6) !=
X Craps_GetBet(&OldTable, craps_DontComeOdds6))) {
X if (num = Craps_GetBet(&Table, craps_DontCome6)) {
X if (Craps_GetBet(&Table, craps_DontComeOdds6))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_DontComeOdds6));
X else
X sprintf(buf, " %d ", num);
X wcenter(dontcome6win, buf, 0, 1);
X }
X else {
X wclear(dontcome6win);
X }
X wrefresh(dontcome6win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontCome8) !=
X Craps_GetBet(&OldTable, craps_DontCome8)) ||
X (Craps_GetBet(&Table, craps_DontComeOdds8) !=
X Craps_GetBet(&OldTable, craps_DontComeOdds8))) {
X if (num = Craps_GetBet(&Table, craps_DontCome8)) {
X if (Craps_GetBet(&Table, craps_DontComeOdds8))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_DontComeOdds8));
X else
X sprintf(buf, " %d ", num);
X wcenter(dontcome8win, buf, 0, 1);
X }
X else {
X wclear(dontcome8win);
X }
X wrefresh(dontcome8win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontCome9) !=
X Craps_GetBet(&OldTable, craps_DontCome9)) ||
X (Craps_GetBet(&Table, craps_DontComeOdds9) !=
X Craps_GetBet(&OldTable, craps_DontComeOdds9))) {
X if (num = Craps_GetBet(&Table, craps_DontCome9)) {
X if (Craps_GetBet(&Table, craps_DontComeOdds9))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_DontComeOdds9));
X else
X sprintf(buf, " %d ", num);
X wcenter(dontcome9win, buf, 0, 1);
X }
X else {
X wclear(dontcome9win);
X }
X wrefresh(dontcome9win);
X }
X if (full || (Craps_GetBet(&Table, craps_DontCome10) !=
X Craps_GetBet(&OldTable, craps_DontCome10)) ||
X (Craps_GetBet(&Table, craps_DontComeOdds10) !=
X Craps_GetBet(&OldTable, craps_DontComeOdds10))) {
X if (num = Craps_GetBet(&Table, craps_DontCome10)) {
X if (Craps_GetBet(&Table, craps_DontComeOdds10))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_DontComeOdds10));
X else
X sprintf(buf, " %d ", num);
X wcenter(dontcome10win, buf, 0, 1);
X }
X else {
X wclear(dontcome10win);
X }
X wrefresh(dontcome10win);
X }
X if (full || (Craps_GetBet(&Table, craps_Place4) !=
X Craps_GetBet(&OldTable, craps_Place4)) ||
X (Craps_Bought4(&Table) != Craps_Bought4(&OldTable))) {
X if (num = Craps_GetBet(&Table, craps_Place4)) {
X sprintf(buf, " %s%d ", Craps_Bought4(&Table) ? "buy " : "", num);
X wcenter(place4win, buf, 0, 1);
X }
X else {
X wclear(place4win);
X }
X wrefresh(place4win);
X }
X if (full || (Craps_GetBet(&Table, craps_Place5) !=
X Craps_GetBet(&OldTable, craps_Place5))) {
X if (num = Craps_GetBet(&Table, craps_Place5)) {
X sprintf(buf, " %d ", num);
X wcenter(place5win, buf, 0, 1);
X }
X else {
X wclear(place5win);
X }
X wrefresh(place5win);
X }
X if (full || (Craps_GetBet(&Table, craps_Place6) !=
X Craps_GetBet(&OldTable, craps_Place6))) {
X if (num = Craps_GetBet(&Table, craps_Place6)) {
X sprintf(buf, " %d ", num);
X wcenter(place6win, buf, 0, 1);
X }
X else {
X wclear(place6win);
X }
X wrefresh(place6win);
X }
X if (full || (Craps_GetBet(&Table, craps_Place8) !=
X Craps_GetBet(&OldTable, craps_Place8))) {
X if (num = Craps_GetBet(&Table, craps_Place8)) {
X sprintf(buf, " %d ", num);
X wcenter(place8win, buf, 0, 1);
X }
X else {
X wclear(place8win);
X }
X wrefresh(place8win);
X }
X if (full || (Craps_GetBet(&Table, craps_Place9) !=
X Craps_GetBet(&OldTable, craps_Place9))) {
X if (num = Craps_GetBet(&Table, craps_Place9)) {
X sprintf(buf, " %d ", num);
X wcenter(place9win, buf, 0, 1);
X }
X else {
X wclear(place9win);
X }
X wrefresh(place9win);
X }
X if (full || (Craps_GetBet(&Table, craps_Place10) !=
X Craps_GetBet(&OldTable, craps_Place10)) ||
X (Craps_Bought10(&Table) != Craps_Bought10(&Table))) {
X if (num = Craps_GetBet(&Table, craps_Place10)) {
X sprintf(buf, " %s%d ", Craps_Bought10(&Table) ? "buy " : "", num);
X wcenter(place10win, buf, 0, 1);
X }
X else {
X wclear(place10win);
X }
X wrefresh(place10win);
X }
X if (full || (Craps_GetBet(&Table, craps_Come4) !=
X Craps_GetBet(&OldTable, craps_Come4)) ||
X (Craps_GetBet(&Table, craps_ComeOdds4) !=
X Craps_GetBet(&OldTable, craps_ComeOdds4)) ||
X ((Craps_Point(&Table) == 4) && (Craps_Point(&OldTable) !=
X 4)) ||
X ((Craps_Point(&Table) != 4) && (Craps_Point(&OldTable) == 4))) {
X if (num = Craps_GetBet(&Table, craps_Come4)) {
X if (Craps_GetBet(&Table, craps_ComeOdds4))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_ComeOdds4));
X else
X sprintf(buf, " %d ", num);
X wcenter(come4win, buf, 0, 1);
X }
X else {
X if (Craps_Point(&Table) == 4)
X wcenter(come4win, "*****", 0, 1);
X else
X wclear(come4win);
X }
X wrefresh(come4win);
X }
X if (full || (Craps_GetBet(&Table, craps_Come5) !=
X Craps_GetBet(&OldTable, craps_Come5)) ||
X (Craps_GetBet(&Table, craps_ComeOdds5) !=
X Craps_GetBet(&OldTable, craps_ComeOdds5)) ||
X ((Craps_Point(&Table) == 5) && (Craps_Point(&OldTable) !=
X 5)) ||
X ((Craps_Point(&Table) != 5) && (Craps_Point(&OldTable) == 5))) {
X if (num = Craps_GetBet(&Table, craps_Come5)) {
X if (Craps_GetBet(&Table, craps_ComeOdds5))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_ComeOdds5));
X else
X sprintf(buf, " %d ", num);
X wcenter(come5win, buf, 0, 1);
X }
X else {
X if (Craps_Point(&Table) == 5)
X wcenter(come5win, "*****", 0, 1);
X else
X wclear(come5win);
X }
X wrefresh(come5win);
X }
X if (full || (Craps_GetBet(&Table, craps_Come6) !=
X Craps_GetBet(&OldTable, craps_Come6)) ||
X (Craps_GetBet(&Table, craps_ComeOdds6) !=
X Craps_GetBet(&OldTable, craps_ComeOdds6)) ||
X ((Craps_Point(&Table) == 6) && (Craps_Point(&OldTable) != 6)) ||
X ((Craps_Point(&Table) != 6) && (Craps_Point(&OldTable) == 6))) {
X if (num = Craps_GetBet(&Table, craps_Come6)) {
X if (Craps_GetBet(&Table, craps_ComeOdds6))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_ComeOdds6));
X else
X sprintf(buf, " %d ", num);
X wcenter(come6win, buf, 0, 1);
X }
X else {
X if (Craps_Point(&Table) == 6)
X wcenter(come6win, "*****", 0, 1);
X else
X wclear(come6win);
X }
X wrefresh(come6win);
X }
X if (full || (Craps_GetBet(&Table, craps_Come8) !=
X Craps_GetBet(&OldTable, craps_Come8)) ||
X (Craps_GetBet(&Table, craps_ComeOdds8) !=
X Craps_GetBet(&OldTable, craps_ComeOdds8)) ||
X ((Craps_Point(&Table) == 8) && (Craps_Point(&OldTable) !=
X 8)) ||
X ((Craps_Point(&Table) != 8) && (Craps_Point(&OldTable) == 8))) {
X if (num = Craps_GetBet(&Table, craps_Come8)) {
X if (Craps_GetBet(&Table, craps_ComeOdds8))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_ComeOdds8));
X else
X sprintf(buf, " %d ", num);
X wcenter(come8win, buf, 0, 1);
X }
X else {
X if (Craps_Point(&Table) == 8)
X wcenter(come8win, "*****", 0, 1);
X else
X wclear(come8win);
X }
X wrefresh(come8win);
X }
X if (full || (Craps_GetBet(&Table, craps_Come9) !=
X Craps_GetBet(&OldTable, craps_Come9)) ||
X (Craps_GetBet(&Table, craps_ComeOdds9) !=
X Craps_GetBet(&OldTable, craps_ComeOdds9)) ||
X ((Craps_Point(&Table) == 9) && (Craps_Point(&OldTable) != 9)) ||
X ((Craps_Point(&Table) != 9) && (Craps_Point(&OldTable) == 9))) {
X if (num = Craps_GetBet(&Table, craps_Come9)) {
X if (Craps_GetBet(&Table, craps_ComeOdds9))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_ComeOdds9));
X else
X sprintf(buf, " %d ", num);
X wcenter(come9win, buf, 0, 1);
X }
X else {
X if (Craps_Point(&Table) == 9)
X wcenter(come9win, "*****", 0, 1);
X else
X wclear(come9win);
X }
X wrefresh(come9win);
X }
X if (full || (Craps_GetBet(&Table, craps_Come10) !=
X Craps_GetBet(&OldTable, craps_Come10)) ||
X (Craps_GetBet(&Table, craps_ComeOdds10) !=
X Craps_GetBet(&OldTable, craps_ComeOdds10)) ||
X ((Craps_Point(&Table) == 10) && (Craps_Point(&OldTable) != 10)) ||
X ((Craps_Point(&Table) != 10) && (Craps_Point(&OldTable) == 10))) {
X if (num = Craps_GetBet(&Table, craps_Come10)) {
X if (Craps_GetBet(&Table, craps_ComeOdds10))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_ComeOdds10));
X else
X sprintf(buf, " %d ", num);
X wcenter(come10win, buf, 0, 1);
X }
X else {
X if (Craps_Point(&Table) == 10)
X wcenter(come10win, "*****", 0, 1);
X else
X wclear(come10win);
X }
X wrefresh(come10win);
X }
X if (full || (Craps_Bankroll(&Table) != Craps_Bankroll(&OldTable))) {
X sprintf(buf, "%d", Craps_Bankroll(&Table));
X wcenter(bankrollwin, buf, 0, 0);
X wrefresh(bankrollwin);
X }
X if (full || (Craps_Point(&Table) != Craps_Point(&OldTable))) {
X if (num = Craps_Point(&Table)) {
X sprintf(buf, " %d ", num);
X }
X else {
X strcpy(buf, " COME OUT ");
X }
X wcenter(pointwin, buf, 0, 1);
X wrefresh(pointwin);
X }
X if (full || (Craps_GetBet(&Table, craps_PassLine) !=
X Craps_GetBet(&OldTable, craps_PassLine)) ||
X (Craps_GetBet(&Table, craps_PassLineOdds) !=
X Craps_GetBet(&OldTable, craps_PassLineOdds))) {
X if (num = Craps_GetBet(&Table, craps_PassLine)) {
X if (Craps_GetBet(&Table, craps_PassLineOdds))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_PassLineOdds));
X else
X sprintf(buf, " %d ", num);
X wcenter(passlinewin, buf, 0, 1);
X }
X else {
X wclear(passlinewin);
X }
X wrefresh(passlinewin);
X }
X if (full || (Craps_GetBet(&Table, craps_ComeBox) !=
X Craps_GetBet(&OldTable, craps_ComeBox))) {
X if (num = Craps_GetBet(&Table, craps_ComeBox)) {
X sprintf(buf, " %d ", num);
X wcenter(comewin, buf, 0, 1);
X }
X else {
X wclear(comewin);
X }
X wrefresh(comewin);
X }
X if (full || (Craps_GetBet(&Table, craps_DontPass) !=
X Craps_GetBet(&OldTable, craps_DontPass)) ||
X (Craps_GetBet(&Table, craps_DontPassOdds) !=
X Craps_GetBet(&OldTable, craps_DontPassOdds))) {
X if (num = Craps_GetBet(&Table, craps_DontPass)) {
X if (Craps_GetBet(&Table, craps_DontPassOdds))
X sprintf(buf, " %d/%d ", num,
X Craps_GetBet(&Table, craps_DontPassOdds));
X else
X sprintf(buf, " %d ", num);
X wcenter(dontpasswin, buf, 0, 1);
X }
X else {
X wclear(dontpasswin);
X }
X wrefresh(dontpasswin);
X }
X if (full || (Craps_GetBet(&Table, craps_DontComeBox) !=
X Craps_GetBet(&OldTable, craps_DontComeBox))) {
X if (num = Craps_GetBet(&Table, craps_DontComeBox)) {
X sprintf(buf, " %d ", num);
X wcenter(dontcomewin, buf, 0, 1);
X }
X else {
X wclear(dontcomewin);
X }
X wrefresh(dontcomewin);
X }
X if (full || (Craps_GetBet(&Table, craps_Field) !=
X Craps_GetBet(&OldTable, craps_Field))) {
X if (num = Craps_GetBet(&Table, craps_Field)) {
X sprintf(buf, " %d ", num);
X wcenter(fieldwin, buf, 0, 1);
X }
X else {
X wclear(fieldwin);
X }
X wrefresh(fieldwin);
X }
X if (full || (Craps_GetBet(&Table, craps_Big6) !=
X Craps_GetBet(&OldTable, craps_Big6))) {
X if (num = Craps_GetBet(&Table, craps_Big6)) {
X sprintf(buf, " %d ", num);
X wcenter(big6win, buf, 0, 1);
X }
X else {
X wclear(big6win);
X }
X wrefresh(big6win);
X }
X if (full || (Craps_GetBet(&Table, craps_Big8) !=
X Craps_GetBet(&OldTable, craps_Big8))) {
X if (num = Craps_GetBet(&Table, craps_Big8)) {
X sprintf(buf, " %d ", num);
X wcenter(big8win, buf, 0, 1);
X }
X else {
X wclear(big8win);
X }
X wrefresh(big8win);
X }
X if (full || (Craps_GetBet(&Table, craps_Hard4) !=
X Craps_GetBet(&OldTable, craps_Hard4))) {
X if (num = Craps_GetBet(&Table, craps_Hard4)) {
X sprintf(buf, " %d ", num);
X wcenter(hard4win, buf, 0, 1);
X }
X else {
X wclear(hard4win);
X }
X wrefresh(hard4win);
X }
X if (full || (Craps_GetBet(&Table, craps_Hard6) !=
X Craps_GetBet(&OldTable, craps_Hard6))) {
X if (num = Craps_GetBet(&Table, craps_Hard6)) {
X sprintf(buf, " %d ", num);
X wcenter(hard6win, buf, 0, 1);
X }
X else {
X wclear(hard6win);
X }
X wrefresh(hard6win);
X }
X if (full || (Craps_GetBet(&Table, craps_Hard8) !=
X Craps_GetBet(&OldTable, craps_Hard8))) {
X if (num = Craps_GetBet(&Table, craps_Hard8)) {
X sprintf(buf, " %d ", num);
X wcenter(hard8win, buf, 0, 1);
X }
X else {
X wclear(hard8win);
X }
X wrefresh(hard8win);
X }
X if (full || (Craps_GetBet(&Table, craps_Hard10) !=
X Craps_GetBet(&OldTable, craps_Hard10))) {
X if (num = Craps_GetBet(&Table, craps_Hard10)) {
X sprintf(buf, " %d ", num);
X wcenter(hard10win, buf, 0, 1);
X }
X else {
X wclear(hard10win);
X }
X wrefresh(hard10win);
X }
X if (full || (Craps_GetBet(&Table, craps_OneRoll2) !=
X Craps_GetBet(&OldTable, craps_OneRoll2))) {
X if (num = Craps_GetBet(&Table, craps_OneRoll2)) {
X sprintf(buf, " %d ", num);
X wcenter(oneroll2win, buf, 0, 1);
X }
X else {
X wclear(oneroll2win);
X }
X wrefresh(oneroll2win);
X }
X if (full || (Craps_GetBet(&Table, craps_OneRoll3) !=
X Craps_GetBet(&OldTable, craps_OneRoll3))) {
X if (num = Craps_GetBet(&Table, craps_OneRoll3)) {
X sprintf(buf, " %d ", num);
X wcenter(oneroll3win, buf, 0, 1);
X }
X else {
X wclear(oneroll3win);
X }
X wrefresh(oneroll3win);
X }
X if (full || (Craps_GetBet(&Table, craps_OneRoll11) !=
X Craps_GetBet(&OldTable, craps_OneRoll11))) {
X if (num = Craps_GetBet(&Table, craps_OneRoll11)) {
X sprintf(buf, " %d ", num);
X wcenter(oneroll11win, buf, 0, 1);
X }
X else {
X wclear(oneroll11win);
X }
X wrefresh(oneroll11win);
X }
X if (full || (Craps_GetBet(&Table, craps_OneRoll12) !=
X Craps_GetBet(&OldTable, craps_OneRoll12))) {
X if (num = Craps_GetBet(&Table, craps_OneRoll12)) {
X sprintf(buf, " %d ", num);
X wcenter(oneroll12win, buf, 0, 1);
X }
X else {
X wclear(oneroll12win);
X }
X wrefresh(oneroll12win);
X }
X if (full || (Craps_GetBet(&Table, craps_Any7) !=
X Craps_GetBet(&OldTable, craps_Any7))) {
X if (num = Craps_GetBet(&Table, craps_Any7)) {
X sprintf(buf, " %d ", num);
X wcenter(any7win, buf, 0, 1);
X }
X else {
X wclear(any7win);
X }
X wrefresh(any7win);
X }
X if (full || (Craps_GetBet(&Table, craps_AnyCraps) !=
X Craps_GetBet(&OldTable, craps_AnyCraps))) {
X if (num = Craps_GetBet(&Table, craps_AnyCraps)) {
X sprintf(buf, " %d ", num);
X wcenter(anycrapswin, buf, 0, 1);
X }
X else {
X wclear(anycrapswin);
X }
X wrefresh(anycrapswin);
X }
X if (full || (Craps_Die1(&Table) !=
X Craps_Die1(&OldTable)) ||
X (Craps_Die2(&Table) != Craps_Die2(&OldTable))) {
X sprintf(buf, "%d %d", Craps_Die1(&Table), Craps_Die2(&Table));
X wcenter(dicewin, buf, 0, 1);
X wrefresh(dicewin);
X }
X}
X
XError(err)
XCrapsError_t err;
X{
X char buf[100];
X
X switch (err) {
X case crapserr_NoReturn:
X Message("Cannot take down bet");
X break;
X case crapserr_AlreadyBought:
X Message("Already bought");
X break;
X case crapserr_Nonpositive:
X Message("Bet must be positive");
X break;
X case crapserr_NoBet:
X Message("No bet to take odds on");
X break;
X case crapserr_InsufficientFunds:
X Message("Insufficient funds");
X break;
X case crapserr_NotComeOut:
X Message("Not come-out roll");
X break;
X case crapserr_ComeOut:
X Message("Come-out roll");
X break;
X case crapserr_TooMuch:
X sprintf(buf, "Maximum is $%d", CrapsErrorDatum);
X Message(buf);
X break;
X case crapserr_NotDivisible:
X sprintf(buf, "Bet must be divisible by %d", CrapsErrorDatum);
X Message(buf);
X break;
X }
X}
X
Xint ReadNumber()
X{
X int c, len = 0;
X char buf[100], *bufptr = buf;
X
X buf[0] = '\0';
X wclear(commandwin);
X wrefresh(commandwin);
X while (1) {
X c = Getch("0123456789\n\r\b", 0);
X switch (c) {
X case '\n':
X case '\r':
X if (len)
X return (atoi(buf));
X break;
X case '\b':
X case 127:
X if (len > 0) {
X *(--bufptr) = '\0';
X --len;
X }
X break;
X default:
X *(bufptr++) = c;
X *bufptr = '\0';
X ++len;
X break;
X }
X wclear(commandwin);
X waddstr(commandwin, buf);
X wrefresh(commandwin);
X }
X}
X
XHelp()
X{
X clear();
X addstr("p - pass-line (or odds) dp - don't pass (or odds)\n");
X addstr("c - come bet dc - don't come\n");
X addstr("b6 - big 6 b8 - big 8\n");
X addstr("h22 - hard 4 h33 - hard 6\n");
X addstr("h44 - hard 8 h55 - hard 10\n");
X addstr("2 - one-roll bet on 2 3 - one-roll bet on 3\n");
X addstr("11 - one-roll bet on 11 12 - one-roll bet on 12\n");
X addstr("a7 - any 7 ac - any craps\n");
X addstr("b4 - buy the 4 b10 - buy the 10\n");
X addstr("f - field r - ROLL DICE\n\n");
X addstr("Come-odds, place bets, don't-come odds, and don't place bets\n");
X addstr("are made by typing the desired number, then c, p, dc, or dp.\n");
X addstr("For example:\n\n");
X addstr("4c - come-odds on 4 4p - place 4\n");
X addstr("4dc - don't-come odds on 4 4dp - don't place 4\n\n");
X addstr("Bets are taken down by typing t followed by one of the\n");
X addstr("bet commands above.\n\n");
X addstr("X - Exit program\n");
X addstr(" continue...");
X refresh();
X getch();
X longjmp(LoopEnv, 2);
X}
END_OF_FILE
if test 43812 -ne `wc -c <'vcraps.c'`; then
echo shar: \"'vcraps.c'\" unpacked with wrong size!
fi
# end of 'vcraps.c'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked both archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0

Reply all
Reply to author
Forward
0 new messages