home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
WWIVMODS
/
PRE412.ZIP
/
LOTTERY.C
< prev
next >
Wrap
Text File
|
1988-09-25
|
1KB
|
39 lines
#include <ctype.h>
void lottery() /* DF */
{
char s[5], sr[5], s1[81];
int notgood = 1, i, j, matches = 0;
thisuser.gold -= 3.0;
while (notgood && !hangup)
{
notgood = 0;
prt(2, "Please enter your 4 digit lottery number:");
ansic(4);
input(s, 4);
if (strlen(s) < 4) notgood = 1;
for (i = 0; i <= 3; i++)
if (!isdigit(s[i])) notgood = 1;
if (notgood) pl("Please enter a 4 digit number only.");
}
for (i = 0; i <= 3; i++)
sr[i] = (rand() % 10) + '0';
sr[4] = 0;
for (i = 0; i <= 3; i++)
for (j = 0; j <= 3; j++)
if (sr[i] == s[j]) matches++;
sprintf(s1, "Your guess: %s, actual lottery numbers: %s, number of matches: %d.",
s, sr, matches);
pl(s1);
thisuser.gold += (float)(matches * matches * 2);
if (matches)
sprintf(s1, "You have just won %d gold pieces!", (matches * matches * 2));
else
sprintf(s1, "You did not win any gold. Try again next call.");
pl(s1);
sprintf(s1, "*** Played logoff lottery: Won: %d, Net gain: %d.",
(matches * matches * 2), (matches * matches * 2) - 3);
sysoplog(s1);
}