home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
001-099
/
ff019.lzh
/
BlackJack
/
outcom.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-04-08
|
2KB
|
64 lines
/* outcom.c print outcome of hand(s)
*/
#include "local.h"
#include "bj.h"
#include "hndmgr.h"
static CASH value = {0};
/* outcom - print outcome of hand and compute results
*/
CASH outcom(bet, tophand, isinsur, isdbl)
CASH bet; /* amount of player's bet */
short tophand; /* how many player hands */
bool isinsur; /* player took insurance? */
bool isdbl; /* is player DBLDN? */
{
void prmsg();
bool isbj();
short score();
short h; /* which hand */
value = 0;
if (isinsur && isbj(DEALER))
prmsg(1, 1, "Insurance wins\n", ((bet) / (isdbl ? 4 : 2)));
else if (isinsur)
prmsg(1, 1, "Insurance loses\n", ((-bet) / (isdbl ? 4 : 2)));
if (isbj(DEALER) && !isbj(1))
prmsg(1, 1, "Dealer BJ beats all but BJ", ((-bet) / (isdbl ? 2 : 1)));
else if (isbj(DEALER) && isbj(1))
prmsg(1, 1, "Both BJ: push", (CASH)0);
else if (isbj(1))
prmsg(1, 1, "Your BJ wins 3 for 2", ((3 * bet) / 2));
else {
for (h = 1; h <= tophand; ++h) {
if (21 < score(h))
value -= bet; /* "Bust" message already printed */
else if (score(DEALER) == score(h))
prmsg(h, tophand, "Push", (CASH)0);
else if (score(DEALER) < score(h) || 21 < score(DEALER))
prmsg(h, tophand, "Win", bet);
else
prmsg(h, tophand, "Lose", -bet);
}
}
return (value);
}
/* prmsg - prints appropriate message
*/
static void prmsg(h, tophand, s, delta)
short h; /* which hand */
short tophand; /* how many hands */
char s[]; /* message */
CASH delta; /* change of value ( + | - ) */
{
if (tophand == 2)
printf("On hand %d, ", h);
printf("%s\n", s);
value += delta;
}