[net.sources] The Craps program!

ray@unlv.UUCP (Ray Tripamer) (02/27/86)

I've received many requests to post craps in net.sources, so here it is.
You need to have a curses library on your machine.

					--Ray Tripamer
					University of Nevada, Las Vegas	
					!seismo!unrvax!unlv!ray

------------------------------ CUT HERE ----------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	Makefile
#	READ_ME
#	craps.6
#	dont.c
#	etc.c
#	final.c
#	help.c
#	main.c
#	makeb.c
#	pass.c
#	pay.c
#	prints.c
#	props.c
#	random.c
#	subs.c
#	ext.h
#	types.h
# This archive created: Wed Feb 12 11:10:51 1986
# By:	Ray Tripamer (Unversity of Nevada, Las Vegas)
export PATH; PATH=/bin:$PATH
echo shar: extracting "'Makefile'" '(857 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
XSOURCES =	main.c dont.c etc.c help.c makeb.c pass.c pay.c prints.c \
X		props.c subs.c final.c random.c
XOBJECTS =	main.o dont.o etc.o help.o makeb.o pass.o pay.o prints.o \
X		props.o subs.o final.o random.o
X#
X# Use the following defines:
X#
X#	-DBSD42		for Berkeley Unix 4.2
X#	-DBSD29		for Berkeley Unix 2.9
X#
XCFLAGS  =	-O -DBSD42
X
X#
X# if you are using BSD29, then add the -i option to the cc line
X#
Xcraps:	${OBJECTS}
X	cc ${CFLAGS} -o craps ${OBJECTS} -lcurses -ltermlib -lm
X
Xmain.o:		main.c types.h
Xdont.o:		dont.c types.h ext.h
Xetc.o:		etc.c types.h ext.h
Xhelp.o:		help.c types.h ext.h
Xmakeb.o:	makeb.c types.h ext.h
Xpass.o:		pass.c types.h ext.h
Xpay.o:		pay.c types.h ext.h
Xprints.o:	prints.c types.h ext.h
Xprops.o:	props.c types.h ext.h
Xsubs.o:		subs.c types.h ext.h
Xfinal.o:	final.c types.h ext.h
Xrandom.o:	random.c types.h ext.h
X
Xclean:
X	rm -f craps *.o
SHAR_EOF
if test 857 -ne "`wc -c < 'Makefile'`"
then
	echo shar: error transmitting "'Makefile'" '(should have been 857 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'READ_ME'" '(872 characters)'
if test -f 'READ_ME'
then
	echo shar: will not over-write existing file "'READ_ME'"
else
sed 's/^X//' << \SHAR_EOF > 'READ_ME'
X
X			Some Notes on Installing Craps
X
X	Craps is known to run on BSD2.x and BSD4.x.  If you are running
X	on another UN*X operating system, then is is imperative that
X	you have a curses library, or forget using this program.
X	Also, for other systems, the file random.c will have to be
X	modified for your local random number generator.
X
X	The routine seedrand() seeds the random number generator, and
X	get_rand() returns an random integer between 1 and 6.
X
X	The high roller list uses the system library function qsort(3),
X	so if your system doesn't have it, it must be supplied, or, as an
X	alternative, just comment out the "#define SCORES" from the file
X	"types.h"
X
X	Also, you will have to specify the path for the high roller
X	file, "craps_list", if the define "#define SCORES" is present.
X	It should go in /usr/games/lib.  The name of the directory
X	is in the file "final.c"
SHAR_EOF
if test 872 -ne "`wc -c < 'READ_ME'`"
then
	echo shar: error transmitting "'READ_ME'" '(should have been 872 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'craps.6'" '(1207 characters)'
if test -f 'craps.6'
then
	echo shar: will not over-write existing file "'craps.6'"
else
sed 's/^X//' << \SHAR_EOF > 'craps.6'
X.TH CRAPS 6
X.UC 4
X.SH NAME
Xcraps \- play the game of craps
X.SH SYNOPSIS
X.B /usr/games/craps
X.SH DESCRIPTION
X.PP
X.I Craps
Xis the popular gambling game found in most casinos, legal or otherwise,
Xand is now found on the system.  Although craps has many betting options,
Xit is beyond the scope of this manual to explain every possible bet.
X.PP
XTo get started you really only need to know one command.  The command
X.B ?
Xwill give you a list of the available commands.
X.PP
XThe object of craps is to (of course) beat the house, i.e. leave the
Xgame with more money than when you started.
X.PP
XA "high rollers" list is maintained which keeps track of the amount won by
Xeach person who has played, and also the number of games they have played.
XIt is highly likely that over the long run, the player on the top of the
Xlist is the one who has lost the least amount of money!
X.SH ENVIRONMENT
X.PP
XCRAPSNAME - used to set your name on the High Rollers List.
X.SH AUTHOR
X.PP
XRay Tripamer, University of Nevada, Las Vegas
X:-)
X.SH FILES
X.DT
X/usr/games/lib/craps.list\ \ \ High Roller List
X.br
X.SH SEE ALSO
X"Playboy\'s Guide to Casino Craps"
X.SH BUGS
X.PP
XIf any should arise, please mail them to
Xme at: !seismo!unrvax!unlv!ray
SHAR_EOF
if test 1207 -ne "`wc -c < 'craps.6'`"
then
	echo shar: error transmitting "'craps.6'" '(should have been 1207 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'dont.c'" '(1423 characters)'
if test -f 'dont.c'
then
	echo shar: will not over-write existing file "'dont.c'"
else
sed 's/^X//' << \SHAR_EOF > 'dont.c'
X#include "types.h"
X#include "ext.h"
X
Xpdontln()	/* pay the dont pass line */
X{
X	double bet(),x;
X
X	x=dont+bet(lodds[point],op[point][1],op[point][0]);
X	total=total+x+lodds[point];
X	wins=wins+x;
X	if(dont!=0.0) {
X		sprintf(line,"You won %.2f on the Dont Pass! ~",x);
X		announce(line);
X	}
X	lodds[point]=0.0;
X}
X
Xcdontln()	/* clear the dont pass line */
X{
X	loss=loss+dont+lodds[point];
X	if(dont!=0.0) announce("You lost on Dont Pass! ~");
X	dont=0.0;
X	lodds[point]=0.0;
X}
X
Xpdontb()	/* pay the dont bar */
X{
X	total=total+dcomeb;
X	wins=wins+dcomeb;
X	if(dcomeb!=0.0) announce("You won your Dont Come Bet! ~");
X}
X
Xcdontb()	/* clear the dont bar */
X{
X	loss=loss+dcomeb;
X	if(dcomeb!=0.0) announce("You lost your Dont Come Bar Bet! ~");
X	dcomeb=0.0;
X}
X
Xpdonts()	/* pay all of the dont come points */
X{
X	int i,j=0;
X	double x=0.0,bet();
X
X	for(i=0;i<11;i++) {
X		x=x+dcome[i]+bet(lodds[i],op[i][1],op[i][0]);
X		total=total+dcome[i]+lodds[i];
X		if(dcome[i]!=0.0) j++;
X		dcome[i]=lodds[i]=0.0;
X	}
X	sprintf(line,"You won %.2f on your Dont Come Bet%s~",x,(j==1)?". " :"s. ");
X	if(j) announce(line);
X	total=total+x;
X	wins=wins+x;
X}
X
Xcsdont(n,off)	/* clear a single dont come bet */
Xint n,off;
X{
X	loss=loss+dcome[n]+lodds[n];
X	if(dcome[n]!=0.0) announce("Down in Back! ~");
X	dcome[n]=lodds[n]=0.0;
X}
X
Xdo_dont(n)
Xint n;
X{
X	dcome[n]=dcomeb;
X	if(dcomeb!=0.0) {
X		sprintf(line,"Dont Come moved behind the %d. ~",n);
X		announce(line);
X	}
X	dcomeb=0.0;
X}
SHAR_EOF
if test 1423 -ne "`wc -c < 'dont.c'`"
then
	echo shar: error transmitting "'dont.c'" '(should have been 1423 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'etc.c'" '(1869 characters)'
if test -f 'etc.c'
then
	echo shar: will not over-write existing file "'etc.c'"
else
sed 's/^X//' << \SHAR_EOF > 'etc.c'
X#include "types.h"
X#include "ext.h"
X
Xpplace(n)	/* pay a place bet */
Xint n;
X{
X	double bet(),x;
X
X	x=bet(place[n],plcpays[n][0],plcpays[n][1]);
X	total=total+x;
X	wins=wins+x;
X	if(place[n]!=0.0) {
X		sprintf(line,"You hit your place bet for %.2f! ~",x);
X		announce(line);
X	}
X}
X
Xmove_place(n)
Xint n;
X{
X	if(place[n]!=0.0) {
X		announce("Your place bet is off on the Comeout! ~");
X		if(pass!=0.0) {
X			announce("Your place bet is in your Tray. ~");
X			total=total+place[n];
X			place[n]=0.0;
X		}
X	}
X}
X
Xcplace()	/* clear all place bets */
X{
X	int i,j=0;
X	char line[81];
X
X	for(i=0;i<11;i++) { 
X		if(place[i]!=0.0) j++;
X		loss=loss+place[i];
X		place[i]=0.0;
X	}
X	if(j) {
X		sprintf(line,"You lost your Place Bet%s~",(j>1)?"s. ":". ");
X		announce(line);
X	}
X}
X
Xpfield()
X{
X	double x;
X
X	x=fpays[sum]*field;
X	if(x==0.0) {
X		loss=loss+field;
X		if(field) announce("You lost your Field Bet! ~");
X		field=0.0;
X	} else {
X		wins=wins+x;
X		field=field+x;
X		if(field>LIMIT) {
X			total=total+(field-LIMIT);
X			field=LIMIT;
X		}
X		if(field) {
X			sprintf(line,"You won%s in the field! ~",
X				(sum==2||sum==12)?
X				((sum==12)?" Triple":" Double"):" ");
X			announce(line);
X		}
X	}
X}
X
Xchk_hrd(x)
Xint x;
X{
X	return((x==4)||(x==6)||(x==8)||(x==10));
X}
X
Xchk_plc(x)
Xint x;
X{
X	return((x==4)||(x==5)||(x==6)||(x==8)||(x==9)||(x==10));
X}
X
Xd_or_p(x)
Xint x;
X{
X	if(!x) return(0);
X	if(dont==0.0 && x==point) {
X		msg("You must have a dont pass bet to lay odds.",23,1);
X		return(1);
X	} else if(dcome[x]==0.0 && x!=point) {
X		sprintf(line,"You don't have a dont come bet on %d.",x);
X		msg(line,23,1);
X		return(1);
X	} else return(0);
X}
X
Xc_or_p(x)
Xint x;
X{
X	if(!x) return(0);
X	if(pass==0.0 && x==point) {
X		msg("You must have a pass line bet to take odds.",23,1);
X		return(1);
X	} else if(come[x]==0.0 && x!=point) {
X		sprintf(line,"You don't have a come bet on %d",x);
X		msg(line,23,1);
X		return(1);
X	} else return(0);
X}
SHAR_EOF
if test 1869 -ne "`wc -c < 'etc.c'`"
then
	echo shar: error transmitting "'etc.c'" '(should have been 1869 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'final.c'" '(2341 characters)'
if test -f 'final.c'
then
	echo shar: will not over-write existing file "'final.c'"
else
sed 's/^X//' << \SHAR_EOF > 'final.c'
X#include "types.h"
X#include "ext.h"
X#include <sys/types.h>
X#include <sys/file.h>
X
X/*
X *
X * here is the file name for the high roller list.
X * It will need to be modified for your system.
X *
X */
X
X#ifdef	SCORES
Xchar *file="/users/intern/ray/craps.list";
Xchar *reclock="/users/intern/ray/craps.lock";
X
X
Xtypedef struct node {
X	struct node *next;
X	int uid;
X	long ngames;
X	double amt;
X	char name[15];
X} scores;
X#endif
X
Xfinal(d)
Xint d;
X{
X#ifdef	SCORES
X	FILE *list;
X	int f,sleepct=300,cuid,did=0,i,n=0,comp();
X	long l;
X	double x;
X	char s[15];
X	scores *score;
X
X	cuid=getuid();
X	clear(); refresh();
X	signal(SIGHUP,SIG_IGN);
X	signal(SIGINT,SIG_IGN);
X	while(link(file, reclock) == -1) {
X		perror(reclock);
X		if(!sleepct--) {
X			puts("I give up. Sorry.");
X			puts("Perhaps there is an old record_lock around?");
X			exit(-1);
X		}
X		printf("Waiting for access to record file. (%d)\n",
X			sleepct);
X		fflush(stdout);
X		sleep(1);
X	}
X	if((list=fopen(file,"r"))==NULL) {
X		fprintf(stderr,"can't open %s\n",file);
X		myexit();
X		return(0);
X	}
X	while((fscanf(list,"%d %f %ld %s",&i,&x,&l,s))!=EOF) n++;
X	rewind(list);
X	score=(scores *)malloc((n+1)*sizeof(scores));
X	cuid=getuid();
X	i=0;
X	while(1) {
X		if((fscanf(list,"%d %f %ld %s",
X			&score[i].uid,
X			&score[i].amt,
X			&score[i].ngames,
X			score[i].name))
X		== EOF) break;
X		if(score[i].uid==cuid) {
X			score[i].amt = score[i].amt + (wins-loss);
X			score[i].ngames = score[i].ngames + 1;
X			did=1;
X		}
X		i++;
X	}
X	fclose(list);
X	if(!did) {
X		score[n].uid = cuid;
X		score[n].amt = (wins-loss);
X		score[n].ngames = 1;
X		if(getenv("CRAPSNAME")==NULL)
X			strcpy(score[n].name,getenv("USER"));
X		else strcpy(score[n].name,getenv("CRAPSNAME"));
X		n++;
X	}
X	qsort(score,n,sizeof(scores),comp);
X	list=fopen(file,"w");
X	for(i=0;i<n;i++)
X		fprintf(list,"%d %.2f %ld %s\n",
X		score[i].uid,
X		score[i].amt,
X		score[i].ngames,
X		score[i].name);
X	fclose(list);
X	clear();
X	mvaddstr(0,10,"Name                Total to Date              Games");
X	mvaddstr(1,10,"----------------------------------------------------");
X	refresh();
X	putchar('\n');
X	for(i=0;i<n;i++)
X		printf("          %-15s %17.2f        %11ld\n",score[i].name,score[i].amt,score[i].ngames);
X	myexit();
X#endif
X	return(0);
X}
X
Xcomp(x,y)
Xscores *x,*y;
X{
X	if(x->amt > y->amt) return(-1);
X	if(x->amt == y->amt) return(0);
X	return(1);
X}
X
Xmyexit()
X{
X	unlink(reclock);
X}
SHAR_EOF
if test 2341 -ne "`wc -c < 'final.c'`"
then
	echo shar: error transmitting "'final.c'" '(should have been 2341 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'help.c'" '(1267 characters)'
if test -f 'help.c'
then
	echo shar: will not over-write existing file "'help.c'"
else
sed 's/^X//' << \SHAR_EOF > 'help.c'
X#include "types.h"
X#include "ext.h"
X
Xhelp()
X{
X	clear(); refresh();
X	mvaddstr(0 ,20,"Key        Action");
X	mvaddstr(1 ,20,"---        ------");
X	mvaddstr(2, 20," r         Roll the Dice");
X	mvaddstr(3 ,20," p         Pass Line bet");
X	mvaddstr(4 ,20," d         Dont Pass bet");
X	mvaddstr(5 ,20," c         Come bet");
X	mvaddstr(6 ,20," D         Dont Come bet");
X	mvaddstr(7 ,20," o         Take odds on Pass Line/Come bets");
X	mvaddstr(8 ,20," l         Lay odds on Dont Pass/Dont Come bets");
X	mvaddstr(9 ,20," b         Place bet");
X	mvaddstr(10,20," f         Field bet");
X	mvaddstr(11,20," h         Hardway bet");
X	mvaddstr(12,20," s         Any Seven bet");
X	mvaddstr(13,20," a         Any Craps bet");
X	mvaddstr(14,20," 2         Snake Eyes (two) bet");
X	mvaddstr(15,20," 3         Three bet");
X	mvaddstr(16,20," y         Eeyo-'Leven (Eleven) bet");
X	mvaddstr(17,20," u         Boxcars (Twelve) bet");
X	mvaddstr(18,20," C         Cheat, set the dice for the next roll");
X	mvaddstr(19,20," q         Quit");
X	mvaddstr(20,20," ?         This List");
X	mvaddstr(21,20," !         Shell escape");
X	refresh();
X	msg("Press [space] to continue",23,1);
X	print_board();
X	if(point) mvaddstr(4,pcol[point],"----");
X	pr_bets();
X	cheat=1;
X	roll();
X	cheat=0;
X	update(1);
X}
SHAR_EOF
if test 1267 -ne "`wc -c < 'help.c'`"
then
	echo shar: error transmitting "'help.c'" '(should have been 1267 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'main.c'" '(1859 characters)'
if test -f 'main.c'
then
	echo shar: will not over-write existing file "'main.c'"
else
sed 's/^X//' << \SHAR_EOF > 'main.c'
X/*
X *  I hearby put this program in the Public Domain.  It can be used
X *  in any way, shape or form.
X *
X *  I assume no responsibility for anything this program may procure
X *  (or not procure) on those who use it. :-)
X *
X *  Ray Tripamer,
X *  Unviersity of Nevada, Las Vegas (Yes, that says Las Vegas!)
X *
X */
X#include "types.h"
X
Xint pcol[11] = {0,0,0,0,C+11,C+19,C+27,0,C+35,C+43,C+51};
X
Xchar *keys="pcdDofblhsa23yuCq?!r",line[81];
Xchar *nums[] = {
X	"","","Two","Three","Four","Five","Six","Seven","Eight","Nine",
X	"Ten","Eleven","Twelve"
X};
Xchar *Bets[] = {
X	"pass line:", "come:", "don't pass:", "don't come:",
X	"take odds:", "field:", "place:","lay odds:", "hard way:",
X	"any seven:", "any craps:", "snake eyes:", "ace-duece:",
X	"eleven:", "boxcars:"
X};
X
Xdouble total, wins, loss, otot, olos, owin, handle;
X
Xdouble pass,comeb,come[11],odds[11];
Xdouble dont,dcomeb,dcome[11],lodds[11];
Xdouble place[11],field;
Xdouble hways[11],aseven,acraps,eeyo,boxcars,aces,aceduece;
X
Xint dice[2]={3,4},sum,point,cheat;
Xint plcpays[11][2] = {	{0,0},{0,0},{0,0},{0,0},
X			{9,5},{7,5},{7,6},{0,0},
X			{7,6},{7,5},{9,5} };
Xint op[11][2] ={	{0,0},{0,0},{0,0},{0,0},
X			{2,1},{3,2},{6,5},{0,0},
X			{6,5},{3,2},{2,1} };
Xint hp[11][2] = {	{0,0},{0,0},{0,0},{0,0},
X			{7,1},{0,0},{9,1},{0,0},
X			{9,1},{0,0},{7,1} };
Xint fpays[13] = {0,0,2,1,1,0,0,0,0,1,1,1,3};
X
Xlong numbets=0;
X
Xmain()
X{
X	int stop(), i;
X
X	signal(SIGINT,stop);
X	initscr();
X	noecho();
X	crmode();
X	seedrand();
X	total=100.0;
X	otot=owin=olos=handle=0.0;
X	loss=wins=pass=dont=dcomeb=comeb=0.0;
X	aseven=acraps=aceduece=boxcars=aces=eeyo=0.0;
X	for(i=0;i<11;i++) dcome[i]=come[i]=odds[i]=place[i]=hways[i]=0.0;
X	print_board();
X	update(1);
X	cheat=1;
X	roll();
X	while(1) {
X		make_bets();
X		roll();
X		pay_winners();
X	}
X}
X
Xstop()
X{
X	final();
X	move(23,0); clrtoeol(); refresh();
X	echo();
X	nocrmode();
X	endwin();
X	exit(0);
X}
SHAR_EOF
if test 1859 -ne "`wc -c < 'main.c'`"
then
	echo shar: error transmitting "'main.c'" '(should have been 1859 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'makeb.c'" '(5232 characters)'
if test -f 'makeb.c'
then
	echo shar: will not over-write existing file "'makeb.c'"
else
sed 's/^X//' << \SHAR_EOF > 'makeb.c'
X#include "types.h"
X#include "ext.h"
X
Xmake_bets()
X{
X	int i,fk,bad,y,z;
X	static int fl=0;
X	double getbet(),x,t;
X	char c, *shell = "/bin/csh",*cp="AahLyRUTKrVsc",pp[15];
X
X	pr_bets();
X	cheat=0;
X	while(1) {
X		if((z=zippo())==1) {
X			announce(0);
X			announce("Sorry, but you are FLAT BROKE! ~");
X			announce("Now BEAT IT!! ~");
X			pr_an();
X			stop();
X		} else if(z==2 && !fl) {
X			announce(0);
X			announce("You have no money in your rack, ~");
X			announce("but you still have bets working. ~");
X			fl=1;
X			pr_an();
X			continue;
X		}
X		addline(0);
X		addline("Bet:");
X		c=getchar();
X		if((i=ind(keys,c))== -1) {
X			BEEP;
X			continue;
X		} else {
X			switch(i) {
X				case ROLL:
X					break;
X				case HELP:
X					help();
X					continue;
X				case SHELL:
X					clear(); move(23,1); refresh();
X					echo(); nocrmode();
X					fk=fork();
X					if (fk==0) {
X						setuid(getuid());
X						execl(shell,shell,0);
X					} else wait(0);
X					noecho(); crmode();
X					clear(); 
X					print_board();
X					if(point)
X						mvaddstr(4,pcol[point],"----");
X					pr_bets();
X					update(1);
X					cheat=1;
X					roll();
X					cheat=0;
X					continue;
X				case QUIT:
X					stop();
X				case CHEAT:
X					addline("Enter password:");
X					gs(pp,15);
X					if(strcmp(crypt(pp,"Aa"),cp)) {
X						BEEP;
X						continue;
X					}
X					cheat=1;
X					addline("first die?");
X					dice[0]=(int)getbet(1);
X					if(dice[0]==-1||dice[0]>6) continue;
X					addline("second die?");
X					dice[1]=(int)getbet(1);
X					if(dice[1]==-1||dice[1]>6) continue;
X					continue;
X				case FIELD:
X					if(mbet(i,&field)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case ASEVEN:
X					if(mbet(i,&aseven)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case EEYO:
X					if(mbet(i,&eeyo)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case TWELVE:
X					if(mbet(i,&boxcars)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case TWO:
X					if(mbet(i,&aces)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case THREE:
X					if(mbet(i,&aceduece)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case ACRAPS:
X					if(mbet(i,&acraps)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case HWAY:
X					do {
X						addline(0);
X						addline(Bets[i]);
X						addline(" number?");
X						y=(int)getbet(1);
X						if(y==-1) break;
X					} while(!chk_hrd(y));
X					if(y==-1) continue;
X					t=hways[y];
X					if(mbet(i,&t)==ESC) continue;
X					hways[y]=t;
X					pr_bets();
X					update(0);
X					continue;
X				case DONT:
X					if(point) msg("The point is already established. Try a dont come bet",23,1);
X					else if(mbet(i,&dont)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case DCOME:
X					if(!point)
X						msg("There is no point yet.  Bet on the Dont Pass Line.",23,1);
X					else if(mbet(i,&dcomeb)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case LODDS:
X					do {
X						addline(0);
X						addline(Bets[i]);
X						addline(" number?");
X						y=(int)getbet(1);
X						if(y==-1) break;
X					} while((!chk_plc(y)) ||(d_or_p(y)));
X					if(y==-1) continue;
X					t=lodds[y];
X					if(mbet(i,&t)==ESC) continue;
X					lodds[y]=t;
X					pr_bets();
X					update(0);
X					continue;
X				case PASS:
X					if(point) msg("The point is already established. Try a come bet.",23,1);
X					else if(mbet(i,&pass)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case COME:
X					if(!point)
X						msg("There is no point yet.  Bet on the Pass Line.",23,1);
X					else if(mbet(i,&comeb)==ESC) continue;
X					pr_bets();
X					update(0);
X					continue;
X				case ODDS:
X					do {
X						addline(0);
X						addline(Bets[i]);
X						addline(" number?");
X						y=(int)getbet(1);
X						if(y==-1) break;
X					} while((!chk_plc(y)) ||(c_or_p(y)));
X					if(y==-1) continue;
X					t=odds[y];
X					if(mbet(i,&t)==ESC) continue;
X					odds[y]=t;
X					pr_bets();
X					update(0);
X					continue;
X				case PLACE:
X					do {
X						addline(0);
X						addline(Bets[i]);
X						addline(" number?");
X						y=(int)getbet(1);
X						if(y==-1) break;
X					} while(!chk_plc(y));
X					if(y==-1) continue;
X					t=place[y];
X					if(mbet(i,&t)==ESC) continue;
X					place[y]=t;
X					pr_bets();
X					update(0);
X					continue;
X			}
X			refresh();
X			break;
X		}
X	}
X}
X
Xzippo()
X{
X	double s;
X	int i;
X
X	if(total==0.0) {
X		s=pass+odds[point]+dont+lodds[point];
X		s=s+aseven+eeyo+boxcars+aces+aceduece+acraps;
X		s=s+comeb+dcomeb+field;
X		for(i=0;i<11;i++) {
X			if(i!=point) {s=s+odds[i];s=s+lodds[i];}
X			s=s+place[i]+dcome[i]+come[i]+hways[i];
X		}
X		if(s!=0.0) return(2);
X		else return(1);
X	} else return(0);
X}
X
Xmbet(i,x)
Xint i;
Xdouble *x;
X{
X	int bad=0;
X	double t=0.0;
X
X	do {
X		if(bad) BEEP;
X		bad=0;
X		do {
X			if(t>LIMIT) BEEP;
X			addline(0);
X			addline(Bets[i]);
X			addline(" how much ? $");
X			if((t=getbet(1))== -1.0) return(ESC);
X		} while(t>LIMIT);
X		total += *x;
X		*x = t;
X		total -= *x;
X		if(t!=0.0) {numbets=numbets+1; handle=handle+t;}
X		if(total <0.0) {
X			bad=1;
X			total += *x;
X			*x = 0.0;
X			if(t!=0.0) {numbets=numbets-1; handle=handle-t;}
X		}
X	} while(bad);
X	return(1);
X}
X
Xgs(s,n)
Xchar *s;
Xint n;
X{
X	char c;
X
X	while(1) {
X		c=getchar();
X		if(c=='\n'||c==EOF) break;
X		if(n) {
X			--n;
X			*s++=c;
X		}
X	}
X	*s=0;
X}
SHAR_EOF
if test 5232 -ne "`wc -c < 'makeb.c'`"
then
	echo shar: error transmitting "'makeb.c'" '(should have been 5232 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pass.c'" '(2500 characters)'
if test -f 'pass.c'
then
	echo shar: will not over-write existing file "'pass.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pass.c'
X#include "types.h"
X#include "ext.h"
X
Xdouble bet(x,n,d)
Xdouble x;
Xint n,d;
X{
X	int dollars=(int)x,quarters;
X
X	if(n==0 || d==0 || x==(double)0.0) return(0.0);
X	quarters=(int)((x-(double)dollars)/.25)+((dollars%d)*4);
X	dollars -= (dollars%d);
X	return((double)(((dollars/d*n)+(dollars%d))) +
X	       (double)(((quarters/d)*n*.25)+((double)(quarters%d)*.25)));
X}
X
Xppassln()	/* pay the pass line */
X{
X	double bet(),x;
X
X	x=pass+bet(odds[point],op[point][0],op[point][1]);
X	total=total+x+odds[point];
X	wins=wins+x;
X	if(pass!=0.0) {
X		sprintf(line,"You won %.2f on the Pass Line! ~",x);
X		announce(line);
X	}
X	odds[point]=0.0;
X}
X
Xcpassln()	/* clear the pass line */
X{
X	loss=loss+pass+odds[point];
X	if(pass!=0.0) announce("Line Away! ~");
X	pass=0.0;
X	odds[point]=0.0;
X}
X
Xpcomeb(on)	/* pay the come bar */
X{
X	total=total+comeb;
X	wins=wins+comeb;
X	if(comeb!=0.0) announce("You won your Come Bar Bet! ~");
X	if(on) {
X		total=total+comeb;
X		if(comeb!=0.0) announce("Your Come Bet is back. ~");
X		comeb=0.0;
X	}
X}
X
Xccomeb()	/* clear the come bar */
X{
X	loss=loss+comeb;
X	if(comeb!=0.0) announce("You lost your Come Bar Bet! ~");
X	comeb=0.0;
X}
X
Xccome(off)	/* clear the come points */
Xint off;
X{
X	int i,j=0;
X
X	for(i=0;i<11;i++) {
X		loss=loss+come[i];
X		if(come[i]!=0.0) j++;
X		if(off) total=total+odds[i];
X		else loss=loss+odds[i];
X		come[i]=odds[i]=0.0;
X	}
X	sprintf(line,"Your come %s lost! ~",(j==1) ? "bet":"bets all");
X	if(j) announce(line);
X	if(off && j) announce("But you got your odds back! ~");
X}
X
Xdo_come(n,on)
Xint n,on;
X{
X	double bet(), x;
X
X	x=come[n];
X	if(on) x = x + bet(odds[n],op[n][0],op[n][1]);
X	if(come[n]!=0.0 && comeb!=0.0) {
X		if(come[n]==comeb) {
X			total=total+x;
X			wins=wins+x;
X			sprintf(line,"Off and On on the %d for %.2f. ~",n,x);
X			announce(line);
X		} else {
X			total=total+x+come[n]+odds[n];
X			wins=wins+x;
X			sprintf(line,"You won %.2f on your Come Bet! ~",x);
X			announce(line);
X			announce("You got your come bet");
X			if(odds[n]!=0.0) announce("/odds");
X			announce(" back. ~");
X			come[n]=odds[n]=0.0;
X			come[n]=comeb;
X			comeb=0.0;
X			sprintf(line,"Your come bet got moved to the %d. ~",n);
X			announce(line);
X		}
X	} else if(come[n]!=0.0 && comeb==0.0) {
X		total=total+x+come[n]+odds[n];
X		wins=wins+x;
X		sprintf(line,"You won %.2f on your Come Bet! ~",x);
X		announce(line);
X		if(!on) announce("But your odds were off! ~");
X		come[n]=odds[n]=0.0;
X	} else if(comeb!=0.0) {
X		come[n]=comeb;
X		comeb=0.0;
X		sprintf(line,"Your come bet got moved to the %d. ~",n);
X		announce(line);
X	}
X}
SHAR_EOF
if test 2500 -ne "`wc -c < 'pass.c'`"
then
	echo shar: error transmitting "'pass.c'" '(should have been 2500 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pay.c'" '(1316 characters)'
if test -f 'pay.c'
then
	echo shar: will not over-write existing file "'pay.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pay.c'
X#include "types.h"
X#include "ext.h"
X
Xpay_winners()
X{
X	int clrp=0,mark=0;
X
X	if(sum==7) {
X		if(!point) {
X			announce("Seven, A Natural! ~");
X			ppassln();
X			cdontln();
X			ccome(1);
X			pdonts();
X		} else {
X			announce("Seven out! ~");
X			announce(line);
X			cpassln();
X			cplace();
X			ccome(0);
X			cdontb();
X			pcomeb(1);
X			pdontln();
X			pdonts();
X			do_dont(sum);
X			clrp=1;
X		}
X	} else if(sum==11) {
X		announce("Eee-yo 'LEVEN! ~");
X		if(!point) {
X			ppassln();
X			cdontln();
X		} else {
X			pcomeb(0);
X			cdontb();
X		}
X	} else if(sum==2 || sum==3 || sum==12) {
X		announce("Craps! ");
X		if(sum==2) announce(" - aces! ~");
X		else if(sum==3) announce(" - ace-duece! ~");
X		else announce(" - sixes! ~");
X		if(!point) {
X			cpassln();
X			if(sum!=12) pdontln();
X			else bar_the_12();
X		} else {
X			ccomeb();
X			if(sum!=12) pdontb();
X			else bar_the_12();
X		}
X	} else {
X		sprintf(line,"%s!",nums[sum]);
X		if(dice[1]==dice[0]) strcat(line,", The Hardway!");
X		strcat(line," ~");
X		announce(line);
X		if(sum==point) {
X			ppassln();
X			pplace(sum);
X			cdontln();
X			do_dont(sum);
X			clrp=1;
X			do_come(sum,1);
X		} else {
X			if(point) pplace(sum);
X			else mark=1;
X			csdont(sum,0);
X			do_dont(sum);
X			do_come(sum,(point!=0));
X		}
X	}
X	pfield();
X	props(sum);
X	if(clrp) cl_point();
X	if(mark) mark_point(sum);
X	pr_an();
X	update(0);
X}
SHAR_EOF
if test 1316 -ne "`wc -c < 'pay.c'`"
then
	echo shar: error transmitting "'pay.c'" '(should have been 1316 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'prints.c'" '(5087 characters)'
if test -f 'prints.c'
then
	echo shar: will not over-write existing file "'prints.c'"
else
sed 's/^X//' << \SHAR_EOF > 'prints.c'
X#include "types.h"
X#include "ext.h"
X
Xpr_bets()
X{
X	int i;
X
X	mvaddstr(R+15,C+40,"       ");	/* clear pass line */
X	mvaddstr(R+13,C+40,"       ");	/* clear dont pass */
X	mvaddstr(R+15,C+47,"        ");	/* clear pass line odds */
X	mvaddstr(R+13,C+47,"        "); /* clear dont pass odds */
X	mvaddstr(R+11,C+48,"       ");	/* clear field */
X	mvaddstr(R+8 ,C+48,"       "); 	/* clear come bar */
X	mvaddstr(R+6 ,C+2 ,"       ");	/* clear dont come bar */
X	mvaddstr(R+2 ,D+5 ,"       ");	/* clear any seven */
X	mvaddstr(R+6 ,D+1 ,"       ");	/* clear hard 6 */
X	mvaddstr(R+6 ,D+9 ,"       ");	/* clear hard 10 */
X	mvaddstr(R+10,D+1 ,"       ");	/* clear hard 8 */
X	mvaddstr(R+10,D+9 ,"       ");	/* clear hard 4 */
X	mvaddstr(R+14,D+1 ,"       ");  /* clear eleven */
X	mvaddstr(R+14,D+9 ,"       ");	/* clear twelve */
X	mvaddstr(R+18,D+1 ,"       ");	/* clear snake eyes */
X	mvaddstr(R+18,D+9 ,"       ");	/* clear ace-duece */
X	mvaddstr(R+21,D+5 ,"       ");	/* clear any craps */
X	for(i=0;i<11;i++) {
X		if(chk_plc(i)) {
X			mvaddstr(R+7,pcol[i]-1,"-------"); /* place bets */
X			mvaddstr(R+6,pcol[i]-1,"       "); /* come bet */
X			mvaddstr(R+5,pcol[i]-1,"       "); /* come bet odds */
X			mvaddstr(R+1,pcol[i]-1,"       "); /* done come bet */
X			mvaddstr(R  ,pcol[i]-1,"-------"); /* dont come odds */
X		}
X	}
X	if(pass!=0.0) {move(R+15,C+40); printw("$%.2f",pass);}
X	if(dont!=0.0) {move(R+13,C+40); printw("$%.2f",dont);}
X	if(point && odds[point]!=0.0) {
X		move(R+15,C+47); printw("/$%.2f",odds[point]);
X	}
X	if(point && lodds[point]!=0.0) {
X		move(R+13,C+47); printw("/$%.2f",lodds[point]);
X	}
X	if(field!=0.0) {move(R+11,C+48); printw("$%.2f",field);}
X	if(comeb!=0.0) {move(R+8,C+48); printw("$%.2f",comeb);}
X	if(dcomeb!=0.0) {move(R+6,C+2); printw("$%.2f",dcomeb);}
X	if(aseven!=0.0) {move(R+2,D+5); printw("$%.2f",aseven);}
X	if(hways[6]!=0.0) {move(R+6,D+1); printw("$%.2f",hways[6]);}
X	if(hways[10]!=0.0) {move(R+6,D+9); printw("$%.2f",hways[10]);}
X	if(hways[8]!=0.0) {move(R+10,D+1); printw("$%.2f",hways[8]);}
X	if(hways[4]!=0.0) {move(R+10,D+9); printw("$%.2f",hways[4]);}
X	if(eeyo!=0.0) {move(R+14,D+1); printw("$%.2f",eeyo);}
X	if(boxcars!=0.0) {move(R+14,D+9); printw("$%.2f",boxcars);}
X	if(aces!=0.0) {move(R+18,D+1); printw("$%.2f",aces);}
X	if(aceduece!=0.0) {move(R+18,D+9); printw("$%.2f",aceduece);}
X	if(acraps!=0.0) {move(R+21,D+5); printw("$%.2f",acraps);}
X	for(i=0;i<11;i++) {
X		if(place[i]!=0.0 && chk_plc(i)) {
X			move(R+7,pcol[i]-1);
X			printw("$%.2f",place[i]);
X		}
X		if(come[i]!=0.0 && chk_plc(i)) {
X			move(R+6,pcol[i]-1);
X			printw("$%.2f",come[i]);
X			if(odds[i]!=0.0) {
X				move(R+5,pcol[i]-1);
X				printw("$%.2f",odds[i]);
X			}
X		}
X		if(dcome[i]!=0.0 && chk_plc(i)) {
X			move(R+1,pcol[i]-1);
X			printw("$%.2f",dcome[i]);
X			if(lodds[i]!=0.0) {
X				move(R,pcol[i]-1);
X				printw("$%.2f",lodds[i]);
X			}
X		}
X	}
X	refresh();
X}
X
Xprint_board()
X{
X
X	clear();
Xmvaddstr(R   ,C,"----------------------------------------------------------");
Xmvaddstr(R+1 ,C,"|        |       |       |       |       |       |       |");
Xmvaddstr(R+2 ,C,"|  DONT  -------------------------------------------------");
Xmvaddstr(R+3 ,C,"|  COME  |   4   |   5   |   6   |   8   |   9   |  10   |");
Xmvaddstr(R+4 ,C,"|        |       |       |       |       |       |       |");
Xmvaddstr(R+5 ,C,"| BAR 12 |       |       |       |       |       |       |");
Xmvaddstr(R+6 ,C,"|        |       |       |       |       |       |       |");
Xmvaddstr(R+7 ,C,"----------------------------------------------------------");
Xmvaddstr(R+8 ,C,"|                            C O M E                     |");
Xmvaddstr(R+9 ,C,"----------------------------------------------------------");
Xmvaddstr(R+10,C,"         |   double     F I E L D      triple            |");
Xmvaddstr(R+11,C,"         |     2    3   4   9  10  11    12              |");
Xmvaddstr(R+12,C,"         -------------------------------------------------");
Xmvaddstr(R+13,C,"         |        DONT PASS BAR 12                       |");
Xmvaddstr(R+14,C,"         -------------------------------------------------");
Xmvaddstr(R+15,C,"         |        P A S S    L I N E                     |");
Xmvaddstr(R+16,C,"         -------------------------------------------------");
Xmvaddstr(R   ,D,"-----------------");
Xmvaddstr(R+1 ,D,"| Any Seven 4-1 |");
Xmvaddstr(R+2 ,D,"|               |");
Xmvaddstr(R+3 ,D,"-----------------");
Xmvaddstr(R+4 ,D,"|Hard 6 |Hard 10|");
Xmvaddstr(R+5 ,D,"|  9-1  |  7-1  |");
Xmvaddstr(R+6 ,D,"|       |       |");
Xmvaddstr(R+7 ,D,"-----------------");
Xmvaddstr(R+8 ,D,"|Hard 8 |Hard 4 |");
Xmvaddstr(R+9 ,D,"|  9-1  |  7-1  |");
Xmvaddstr(R+10,D,"|       |       |");
Xmvaddstr(R+11,D,"-----------------");
Xmvaddstr(R+12,D,"|Eleven |Twelve |");
Xmvaddstr(R+13,D,"| 14-1  | 29-1  |");
Xmvaddstr(R+14,D,"|       |       |");
Xmvaddstr(R+15,D,"-----------------");
Xmvaddstr(R+16,D,"|  Two  | Three |");
Xmvaddstr(R+17,D,"| 29-1  |  14-1 |");
Xmvaddstr(R+18,D,"|       |       |");
Xmvaddstr(R+19,D,"-----------------");
Xmvaddstr(R+20,D,"| Any Craps 8-1 |");
Xmvaddstr(R+21,D,"|               |");
Xmvaddstr(R+22,D,"-----------------");
X}
SHAR_EOF
if test 5087 -ne "`wc -c < 'prints.c'`"
then
	echo shar: error transmitting "'prints.c'" '(should have been 5087 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'props.c'" '(2391 characters)'
if test -f 'props.c'
then
	echo shar: will not over-write existing file "'props.c'"
else
sed 's/^X//' << \SHAR_EOF > 'props.c'
X#include "types.h"
X#include "ext.h"
X
Xprops(n)		/* do the proposition bets */
Xint n;
X{
X	int i,j=0,affect;
X	double x,bet();
X
X	if(aseven!=0.0)
X		if(n==7) {
X			x=bet(aseven,4,1);
X			total=total+x;
X			wins=wins+x;
X			sprintf(line,"You won $%.2f on your Any Seven! ~",x);
X			announce(line);
X		} else {
X			loss=loss+aseven;
X			announce("Any Seven Bet Lost! ~");
X			aseven=0.0;
X		}
X	if(acraps!=0.0)
X		if(n==2||n==3||n==12) {
X			x=bet(acraps,8,1);
X			total=total+x;
X			wins=wins+x;
X			sprintf(line,"You won $%.2f on Any Craps! ~",x);
X			announce(line);
X		} else {
X			loss=loss+acraps;
X			announce("Any Craps Bet Lost! ~");
X			acraps=0.0;
X		}
X	if(eeyo!=0.0)
X		if(n==11) {
X			x=bet(eeyo,14,1);
X			total=total+x;
X			wins=wins+x;
X			sprintf(line,"You won $%.2f on Eleven! ~",x);
X			announce(line);
X		} else {
X			loss=loss+eeyo;
X			announce("Eleven Bet Lost! ~");
X			eeyo=0.0;
X		}
X	if(boxcars!=0.0)
X		if(n==12) {
X			x=bet(boxcars,29,1);
X			total=total+x;
X			wins=wins+x;
X			sprintf(line,"You won $%.2f on Boxcars! ~",x);
X			announce(line);
X		} else {
X			loss=loss+boxcars;
X			announce("Boxcars Bet Lost! ~");
X			boxcars=0.0;
X		}
X	if(aces!=0.0)
X		if(n==2) {
X			x=bet(aces,29,1);
X			total=total+x;
X			wins=wins+x;
X			sprintf(line,"You won $%.2f on Snake Eyes! ~",x);
X			announce(line);
X		} else {
X			loss=loss+aces;
X			announce("Snake Eyes Bet Lost! ~");
X			aces=0.0;
X		}
X	if(aceduece!=0.0)
X		if(n==3) {
X			x=bet(aceduece,14,1);
X			total=total+x;
X			wins=wins+x;
X			sprintf(line,"You won $%.2f on Threee Bet! ~",x);
X			announce(line);
X		} else {
X			loss=loss+aceduece;
X			announce("Three Bet Lost! ~");
X			aceduece=0.0;
X		}
X	for(affect=0,i=0;i<11;i++) {
X		if(hways[i]!=0.0) j++;
X		if(hways[i]!=0.0 && n==7)
X			if(point) {loss=loss+hways[i]; hways[i]=0.0;}
X			else affect=1;
X		if(hways[i]!=0.0 && n==i && dice[0]==dice[1])
X			if(point) {
X				if(i==4||i==10) x=bet(hways[i],7,1);
X				else x=bet(hways[i],9,1);
X				total=total+x;
X				wins=wins+x;
X				sprintf(line,"You won $%.2f on the Hard %s.~",x,nums[i]);
X				announce(line);
X			} else affect=1;
X		if(hways[i]!=0.0 && n==i && dice[0]!=dice[1])
X			if(point) {
X				loss=loss+hways[i];
X				hways[i]=0.0;
X				sprintf(line,"Hard %s Down! ~",nums[i]);
X				announce(line);
X			} else affect=1;
X	}
X	sprintf(line,"Hardway Bet%sDown! ~",(j==1)?" ":"s ");
X	if(n==7 && j && point) announce(line);
X	if(j && !point && affect) announce("Hardways off on the Comeout! ~");
X}
SHAR_EOF
if test 2391 -ne "`wc -c < 'props.c'`"
then
	echo shar: error transmitting "'props.c'" '(should have been 2391 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'random.c'" '(518 characters)'
if test -f 'random.c'
then
	echo shar: will not over-write existing file "'random.c'"
else
sed 's/^X//' << \SHAR_EOF > 'random.c'
X#include "types.h"
X#include "ext.h"
X#ifdef	BSD42
X#include <sys/time.h>
X#endif
X
X/*
X * seed the random number generator
X *
X */
Xseedrand()
X{
X#ifdef BSD42
X	struct timeval tp;
X	struct timezone tpz;
X#endif
X
X#ifdef BSD42
X	gettimeofday(&tp,&tpz);
X	srandom((int)tp.tv_sec);
X#else
X	randomize();
X#endif
X}
X
X/*
X * get_rand - return a random number 1-6
X *
X */
Xget_rand()
X{
X#ifdef BSD42
X	long random();
X#else
X	double ranm();
X#endif
X
X#ifdef BSD42
X	return( (int) random() % 6 + 1);
X#else
X	return( (int) (ranm() * 6.0) + 1.0);
X#endif
X}
SHAR_EOF
if test 518 -ne "`wc -c < 'random.c'`"
then
	echo shar: error transmitting "'random.c'" '(should have been 518 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'subs.c'" '(4380 characters)'
if test -f 'subs.c'
then
	echo shar: will not over-write existing file "'subs.c'"
else
sed 's/^X//' << \SHAR_EOF > 'subs.c'
X#include "types.h"
X#include "ext.h"
X
Xchar bark[600];
X
Xclrtocol(n)
Xint n;
X{
X	int y,x,x1;
X
X	getyx(stdscr,y,x); x1=x;
X	while(x<=n) mvaddch(y,x++,' ');
X	move(y,x1);
X}
X
Xind(s,c)
Xchar *s,c;
X{
X	int i;
X
X	for(i=0;*s;i++,s++) if(*s==c) break;
X	if(!(*s)) return(-1);
X	else return(i);
X}
X
Xmsg(s,y,x)
Xchar *s;
X{
X	char c;
X
X	move(y,x); clrtocol(D-1); refresh();
X	printw("%s-More-",s); refresh();
X	while((c=getchar())!=' ') BEEP;
X}
X
Xaddline(s)
Xchar *s;
X{
X	static int acol=1;
X	if(!s) {
X		move(23,1); clrtoeol(); refresh(); acol=1;
X	} else {
X		if(acol+strlen(s) > 70) acol=1;
X		move(23,acol); clrtoeol(); printw("%s ",s); refresh();
X		acol += strlen(s)+1;
X	}
X}
X
Xdouble getbet(half)
Xint half;
X{
X	char c;
X	int nd=0,dot=0,dc=0;
X	double i=0.0,frac=0.0;
X
X	while(1) {
X		c=getchar();
X		if(c=='\n') {
X			if(frac==0.20||frac==0.70) {BEEP; continue;}
X			else break;
X		}
X		if((c<'0' || c>'9')&&(c!='.')&&(c!=(char)8)&&(c!=ESC)) BEEP;
X		else if(c==ESC) return(-1.0);
X		else if(c=='.') {
X			if(dot==1) BEEP;
X			else {
X				dot=1;
X				addch(c); refresh();
X			}
X		} else if(c==(char)8) {
X			if(!nd && (!dc && !dot)) BEEP;
X			if(dc) {
X				if(frac==0.25) frac=0.20;
X				else if(frac==0.75) frac=0.70;
X				else if(frac==0.50 && dc==2) frac=0.50;
X				else if(frac==0.50) frac=0.0;
X				else if(frac==0.20) frac=0.0;
X				else if(frac==0.70) frac=0.0;
X			}
X			if(nd) i = (float) ((int) (i/10.0));
X			if(nd || dc || dot) {
X				addch((char)8); addch(' '); addch((char)8);
X				refresh();
X				if(dc) dc--;
X				else if(dot && !dc) dot=0;
X				else if(nd) nd--;
X			}
X		} else {
X			if(dot)
X				switch(dc) {
X					case 0: if(c=='2'||c=='5'||c=='7') {
X							frac=(double)(c-'0')/10.0;
X							dc++;
X							addch(c); refresh();
X						} else BEEP;
X						break;
X					case 1:	if(c=='5') {
X							if(frac==.2||frac==.7) {
X								frac=frac+0.05;
X								dc++;
X								addch(c);
X								refresh();
X							} else BEEP;
X						} else if(c=='0') {
X							if(frac==.5) {
X								frac=0.5;
X								dc++;
X								addch(c);
X								refresh();
X							} else BEEP;
X						} else BEEP;
X						break;
X					default:BEEP;
X				}
X			else {
X				if(nd==3) {BEEP; continue;}
X				i = (i*10.0) + c - '0';
X				nd++;
X				addch(c); refresh();
X			}
X		}
X	}
X	return(i+frac);
X}
X
Xannounce(s)
Xchar *s;
X{
X	if(!s) bark[0]=0;
X	else strcat(bark,s);
X}
X
Xpr_an()
X{
X	int i=0,j=0,k=0,l,K=11;
X	char temp[81];
X
X	line[0]=0;
X	while(bark[i]) {
X		while(bark[i] != '~') temp[j++]=bark[i++];
X		i++;
X		temp[j]=0;
X		l=K+((D-7-K-strlen(temp))/2);
X		move(18,K); clrtocol(D-1); refresh();
X		msg(temp,18,l);
X		j=0;
X	}
X	move(18,K); clrtocol(D-1); refresh();
X}
X
Xupdate(force)
Xint force;
X{
X	if(otot!=total || olos!=loss || owin!=wins || force) {
X		move(20,6); clrtocol(D-1); refresh();
X		printw("Rack:%.2f",total);
X		printw("  Winnings:%.2f",wins);
X		printw("  Losses:%.2f",loss);
X		refresh();
X	}
X	otot=total; olos=loss; owin=wins;
X}
X
Xroll()
X{
X	int i,k,l;
X
X	announce(0);
X	mvaddstr(10,2,"-------");
X	mvaddstr(11,2,"|     |");
X	mvaddstr(12,2,"|     |");
X	mvaddstr(13,2,"|     |");
X	mvaddstr(14,2,"-------");
X	mvaddstr(15,2,"-------");
X	mvaddstr(16,2,"|     |");
X	mvaddstr(17,2,"|     |");
X	mvaddstr(18,2,"|     |");
X	mvaddstr(19,2,"-------");
X	if(cheat) {
X		spots(dice[0],11,3);
X		spots(dice[1],16,3);
X	} else for(i=0;i<10;i++) {
X		dice[0]=get_rand();
X		dice[1]=get_rand();
X		spots(dice[0],11,3);
X		spots(dice[1],16,3);
X		refresh();
X	}
X	sum=dice[0]+dice[1];
X}
X
Xspots(i,y,x)
Xint i,y,x;
X{
X	switch(i) {
X		case 1:
X			mvaddstr(y,x,"     ");
X			mvaddstr(y+1,x,"  o  ");
X			mvaddstr(y+2,x,"     ");
X			break;
X		case 2:
X			mvaddstr(y,x,"o    ");
X			mvaddstr(y+1,x,"     ");
X			mvaddstr(y+2,x,"    o");
X			break;
X		case 3:
X			mvaddstr(y,x,"o    ");
X			mvaddstr(y+1,x,"  o  ");
X			mvaddstr(y+2,x,"    o");
X			break;
X		case 4:
X			mvaddstr(y,x,"o   o");
X			mvaddstr(y+1,x,"     ");
X			mvaddstr(y+2,x,"o   o");
X			break;
X		case 5:
X			mvaddstr(y,x,"o   o");
X			mvaddstr(y+1,x,"  o  ");
X			mvaddstr(y+2,x,"o   o");
X			break;
X		case 6:
X			mvaddstr(y,x,"o   o");
X			mvaddstr(y+1,x,"o   o");
X			mvaddstr(y+2,x,"o   o");
X			break;
X	}
X}
X
Xmark_point(n)
Xint n;
X{
X	mvaddstr(4,pcol[n],"----");
X	refresh();
X	point=n;
X	sprintf(line,"The Point is %d! ~",point);
X	announce(line);
X	move_place(n);
X}
X
Xcl_point()
X{
X	mvaddstr(4,pcol[point],"    ");
X	refresh();
X	point=0;
X}
X
Xbar_the_12()
X{
X	int i,j=0;
X
X	for(i=0;i<11;i++) if(dcome[i]!=0.0) j=1;
X	if(dcomeb!=0.0) j=1;
X	if(j || (dont!=0.0 && !point)) announce("Bar the Dont's! ~");
X}
SHAR_EOF
if test 4380 -ne "`wc -c < 'subs.c'`"
then
	echo shar: error transmitting "'subs.c'" '(should have been 4380 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'ext.h'" '(493 characters)'
if test -f 'ext.h'
then
	echo shar: will not over-write existing file "'ext.h'"
else
sed 's/^X//' << \SHAR_EOF > 'ext.h'
Xextern int pcol[11];
X
Xextern char *keys,line[81];
Xextern char *nums[];
Xextern char *Bets[];
X
Xextern double total, wins, loss, otot, olos, owin, handle;
X
Xextern double pass,comeb,come[11],odds[11];
Xextern double dont,dcomeb,dcome[11],lodds[11];
Xextern double place[11],field;
Xextern double hways[11],aseven,acraps,eeyo,boxcars,aces,aceduece;
X
Xextern int dice[2],sum,point,cheat;
Xextern int plcpays[11][2];
Xextern int op[11][2];
Xextern int hp[11][2];
Xextern int fpays[13];
X
Xextern long numbets;
SHAR_EOF
if test 493 -ne "`wc -c < 'ext.h'`"
then
	echo shar: error transmitting "'ext.h'" '(should have been 493 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'types.h'" '(617 characters)'
if test -f 'types.h'
then
	echo shar: will not over-write existing file "'types.h'"
else
sed 's/^X//' << \SHAR_EOF > 'types.h'
X#include <curses.h>
X#include <signal.h>
X#define SCORES				/* yes, maintain a high score list */
X					/* if you dont want to, comment it */
X					/* out 				   */
X#define BEEP	putchar((char)7)
X#define ESC	(char)27
X#define LIMIT	500.00
X#define SLIMIT	1000.00
X#define R	0
X#define C	1
X#define D	C+62
X#define PASS	0
X#define COME	1
X#define DONT	2
X#define DCOME	3
X#define ODDS	4
X#define FIELD	5
X#define PLACE	6
X#define LODDS	7
X#define HWAY	8
X#define ASEVEN	9
X#define	ACRAPS	10
X#define	TWO	11
X#define	THREE	12
X#define	EEYO	13
X#define TWELVE	14
X#define CHEAT	15
X#define QUIT	16
X#define HELP	17
X#define SHELL	18
X#define ROLL	19
SHAR_EOF
if test 617 -ne "`wc -c < 'types.h'`"
then
	echo shar: error transmitting "'types.h'" '(should have been 617 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0

reintom@rocky2.UUCP (Tom Reingold) (03/02/86)

I compiled it and it seemed to run on the VAX 11/780.  When I tried
to quit, it tried to access a lock file that is obviously local to
the author's system.  It looped endlessly, waiting for access.  I
could not use my break key to stop the process!  This is a serious
bug.

I had to disconnect from the host, log back in, type "ps -x", and
kill my login and craps processes.

Incidentally, in case you are interested, the program would not
compile on another machine running 4.2BSD.  The machine is a Sperry
7000/40 which is based on a handful of 68000 chips.

Tom Reingold
New York City