home *** CD-ROM | disk | FTP | other *** search
- /*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;
- }
- }
-