home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3281
/
draw.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-02
|
2KB
|
101 lines
/*LINTLIBRARY*/
/*
* Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
*
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, provided that the above copyright
* notice appear in all copies and that both the copyright notice and
* this permission notice appear in supporting documentation. This software
* is provided "as is" without express or implied warranty. However, the
* author retains all Copyright priviliges and rights to renumeration if
* this software is sold.
*
* Also, and very important. This game is for recrecation ONLY and is NOT
* to be used for gambling in any way.
*/
/*
* draw.c - Select which card to hold (You've got to know when to hold-um, ..
*/
#include "vid_local.h"
#include "vid_curses.h"
#include "vid_poker.h"
extern int bet;
extern int credits;
void draw(deck, value, suite)
int *deck,
*value;
char **suite;
{
int count, /* count of cards to be drawn */
index, /* loop index */
win, /* amount won on hand */
key = -1, /* keys pressed during draw */
draw_card=5, /* The first draw card */
hold[5]; /* mark the cards help */
for (index=0; index < 5; ++index)
hold[index] = 0;
mvaddstr(19, 0, "\t\t\t\t\t\t\t\t\t\t");
mvaddstr(21, 0, "Keys 1-5 will hold/cancel cards, space/return to draw:");
refresh();
while ( key != ' ' && key != '\r' )
{
if( (key=mvgetch(21,56)) >= '0' && key <= '5' )
{
addstr("\010 ");
move(19, 4+(15 * ((key - '0')-1)));
if ( hold[(key - '0') - 1] )
{
addstr(" ");
hold[(key - '0' -1) ] = 0;
}
else
{
addstr("HOLD");
hold[ (key - '0' -1) ] = 1;
}
}
else
if ( key != '\r' && key != ' ' )
{
putchar('\007');
fflush(stdout);
}
refresh();
}
/* cards selected, now draw */
count=0;
for(index=0; index < 5; ++index)
if ( hold[index] )
++count;
count = 5 - count;
deal(deck, count);
setup_deck(deck, value, suite, count);
/* Replace the discarded cards */
for( index=0; index < 5 && count; ++index )
{
if ( hold[index] == 0 ) /* card NOT held */
{
value[index] = value[draw_card];
suite[index] = suite[draw_card++];
--count;
}
}
display_hand(value, suite, 5);
sort(value, suite, 5);
win = bet * display_val(id_hand(value, suite));
credits += win;
mvprintw(22, 65, "Credits %-6d ", credits);
mvprintw(23, 65, "Winner %-6d ", win);
refresh();
}