home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3281
/
deal.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-02
|
1KB
|
55 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.
*/
/*
* deal.c - generate the random numbers that will represent cards.
*/
#include "vid_poker.h"
#include <sys/types.h>
extern double drand48();
extern void srand48();
extern time_t time();
static time_t seed=0;
void deal(deck, numcards)
int *deck, /* 52 card deck */
numcards; /* number of cards requested */
{
int check, /* index for preventing dup cards */
count=0; /* count of cards already delt (0 or 5) */
if ( seed == (time_t)0 )
{
seed=time(&seed);
(void)srand48(seed);
}
if ( deck[0] != 0 )
numcards += (count=5); /* we are on the draw */
for (; count < numcards; ++count)
{
deck[count] = 52 * drand48()+1;
for ( check=0; check < count; ++check )
if ( deck[check] == deck[count] )
--count;
}
}