home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////
-
- // A Lottery time gambling program written and copyright by Mark Taylor. //
-
- // //
-
- // Allows a user to gamble his online time left,against a set number of //
-
- // lines of lottery type numbers ie 6 numbers per line. //
-
- // The maximum number of lines allowed is 10,but if a user does'nt have //
-
- // time left then only the time/bet can be chosen. //
-
- // Most of the defines can be changed with no other changes to the program //
-
- // The values of mine are based on a User having 60 mins a day on-line time//
-
- // //
-
- // I use Maximus V3.01 for OS/2,but it should work with Dos systems //
-
- // To use this program I place it on the main menu with the following line //
-
- // Mex m\timelotto Disgrace "Time Lottery" //
-
- // //
-
- /////////////////////////////////////////////////////////////////////////////
-
-
-
- /////////////////////////////////////////////////////////////////////////////
-
- // Normal rules apply,this is my copyrighted program //
-
- // //
-
- // If you use and like the program please either netmail or email me at //
-
- // the address' below.If you like to send some money,then let me know and //
-
- // I'll give you my home address :) //
-
- // //
-
- // You may alter this program for YOUR OWN USE ONLY,you cannot alter it //
-
- // and send it out in a modified form. //
-
- // I'd welcome comments,bug reports,ideas or code to be added //
-
- // You may reach me at : 2:253/35@fidonet //
-
- // 240:360/45@mercury //
-
- // 81:444/25@os2net //
-
- // mark.taylor@zetnet.co.uk //
-
- // mark@trythat.coracle.com //
-
- /////////////////////////////////////////////////////////////////////////////
-
-
-
-
-
- #include <max.mh>
-
- #include <rand.mh>
-
-
-
- #define VERSION " V1.1\n" // Version number
-
-
-
- #define MAX_LINES 10 // Maximum number of lines,use the users screen length
-
- #define RANDOM 49 // Maximum value of number to pick
-
- #define BALLS 6 // Number of random numbers to pick per line
-
- #define TRY 50 // Number of random numbers before one is picked
-
- #define BET 5 // Number of minutes to gamble on each line
-
- #define MATCHED_2 2 // Number of minutes given for 2 numbers matched per line
-
- #define MATCHED_3 5 // Number of minutes given for 3 numbers matched per line
-
- #define MATCHED_4 10 // Number of minutes given for 4 numbers matched per line
-
- #define MATCHED_5 15 // Number of minutes given for 5 numbers matched per line
-
- #define MATCHED_6 25 // Number of minutes given for 6 numbers matched per line
-
- #define MAX_TIME 120 // Maxium of time allowed for each user to be added
-
-
-
- int: minutes_won ; // total minutes won,if any :)
-
- string: blanks ; // Blank line
-
-
-
- array [1..BALLS] of int: computer_balls ; // Array for chosen balls
-
- array [1..BALLS] of int: user_balls ; // Array for user chosen lottery balls
-
-
-
- // Prototypes
-
- string centre(string: s1) ;
-
- void cls() ;
-
- void print_title() ;
-
- void pick_numbers(array [1..BALLS] of int: balls) ;
-
- int getrandom() ;
-
- void sort_numbers(array[1..BALLS] of int: balls) ;
-
- void get_user_numbers() ;
-
- int get_number_of_trys() ;
-
- void print_line(array[1..BALLS] of int: balls,int: x) ;
-
- int check_for_match(int: ball_to_check) ;
-
- int main() ;
-
- void help() ;
-
-
-
-
-
- // Centre Output
-
- string centre(string: s1)
-
- {
-
- string: s2;
-
- int: i1;
-
- s2:="\r";
-
- for(i1:=1; i1<=(((term_width()-2)-strlen(s1))/2); i1:=i1+1)
-
- { s2:=s2+" "; }
-
- s2:=s2+s1;
-
- return s2;
-
- }
-
-
-
- // Clear Screen
-
- void cls()
-
- {
-
- print("\x0c");
-
- }
-
-
-
- // Just print out title and advert etc..
-
- void print_title()
-
- {
-
- cls() ;
-
- print(COL_LCYAN) ;
-
- print(centre("Lottery Time Gamble"+VERSION)) ;
-
- print(centre("Written By Mark Taylor (c)\n")) ;
-
- print(centre("TryThat SoftWare 1996\n")) ;
-
- print(COL_WHITE"\n") ;
-
- }
-
-
-
- // computer picked numbers
-
- void pick_numbers(array [1..BALLS] of int: balls)
-
- {
-
- int: i,x,test,number ;
-
-
-
- print(AVATAR_GOTO,(char)10,(char)40,COL_WHITE " ") ;
-
- print(AVATAR_GOTO,(char)10,(char)40,COL_WHITE "Picking Numbers ") ;
-
-
-
- for(i := 1 ; i <= BALLS ; i := i+1)
-
- {
-
- balls[i] := 50 ; // Set ball to a number,that is false
-
- test := FALSE ;
-
- while(test = FALSE)
-
- {
-
- test := TRUE ;
-
- number := getrandom() ; // Get a random ball
-
- // Make sure no dupes
-
- for(x := 1 ; x < BALLS+1 ; x := x+1)
-
- if(balls[x] = number)
-
- test := FALSE ;
-
- }
-
- balls[i] := number ;
-
- }
-
- sort_numbers(balls) ;
-
- }
-
-
-
- // get a random number and print spinning bar
-
- int getrandom()
-
- {
-
- int: number,z ;
-
-
-
- for(z := 0 ; z < TRY ; z := z+1)
-
- {
-
- number := (rand()%RANDOM)+1 ; // Get a random number
-
- if(z/4 = 0)
-
- print(AVATAR_GOTO,(char)10,(char)60,COL_WHITE "\\") ;
-
- if(z/8 = 0)
-
- print(AVATAR_GOTO,(char)10,(char)60,COL_WHITE "-") ;
-
- if(z/12 = 0)
-
- print(AVATAR_GOTO,(char)10,(char)60,COL_WHITE "/") ;
-
- if(z/16 = 0)
-
- print(AVATAR_GOTO,(char)10,(char)60,COL_WHITE "|") ;
-
- }
-
- print(AVATAR_GOTO,(char)10,(char)60,COL_WHITE " ") ;
-
-
-
- return number ;
-
- }
-
-
-
- // Put balls into order
-
- void sort_numbers(array[1..BALLS] of int: balls)
-
- {
-
- // There may be a faster way to sort,but then again there are'nt many numbers
-
-
-
- int: swtch,x,temp ;
-
-
-
- swtch := TRUE ;
-
- while(swtch = TRUE)
-
- {
-
- swtch := FALSE ;
-
- for(x := 1; x < BALLS ; x := x+1)
-
- if(balls[x] >balls[x+1])
-
- {
-
- temp := balls[x] ;
-
- balls[x] := balls[x+1] ;
-
- balls[x+1] := temp ;
-
- swtch := TRUE ;
-
- }
-
- }
-
- }
-
-
-
- // get user numbers
-
- void get_user_numbers()
-
- {
-
- int: number,swtch,x,i;
-
- string: get_number,prompt;
-
-
-
- print(AVATAR_GOTO,(char)10,(char)1,blanks) ;
-
- // print line ready to display user numbers
-
- print(AVATAR_GOTO,(char)10,(char)1,"Your Numbers - ") ;
-
-
-
-
-
- for(i := 1 ; i < BALLS+1 ; i := i+1)
-
- {
-
- prompt := "Please enter a number between 1 and "+itostr(RANDOM)+",then press return ";
-
- swtch := TRUE ;
-
- user_balls[i] := 50 ; // set a dummy number
-
- while(swtch = TRUE)
-
- {
-
- while(swtch = TRUE)
-
- {
-
- // Get a number between 1 & RANDOM (49)
-
- print(AVATAR_GOTO,(char)5,(char)1,blanks) ; // Print a line of blanks
-
- print(AVATAR_GOTO,(char)5,(char)1 ) ;
-
- input_str(get_number, INPUT_WORD, 0, 2,prompt);
-
- number := strtoi(get_number) ;
-
- if(number < 1 OR number > RANDOM)
-
- prompt := "You must enter a number between 1 and "+itostr(RANDOM)+" " ;
-
- else
-
- swtch := FALSE ;
-
- }
-
-
-
- // Make sure no dupes
-
- for(x := 1 ; x < BALLS+1 ; x := x+1)
-
- if(user_balls[x] = number)
-
- {
-
- swtch := TRUE ;
-
- prompt := "Please pick a differnt a number " ;
-
- }
-
-
-
- // this is a good number,so use it
-
- if(swtch = FALSE)
-
- {
-
- user_balls[i] := number ;
-
- print(AVATAR_GOTO,(char)10,(char)(15+(i*3)),COL_YELLOW,number,COL_WHITE) ;
-
- }
-
- }
-
- }
-
-
-
- sort_numbers(user_balls) ; // put the balls in order
-
- }
-
-
-
- // get number of lines to bet on
-
- int get_number_of_trys()
-
- {
-
- int: number,swtch ;
-
- long: available_trys ;
-
- string: get_number,prompt ;
-
-
-
- available_trys := timeleft() / BET ; // Get users time left,and see how many bets
-
- if(available_trys > MAX_LINES) // available.
-
- available_trys := MAX_LINES ; // If more than max limit,set it to max limit
-
-
-
- prompt := "You have "+ltostr(timeleft())+" minutes to play with.\n"+
-
- "Enter how many bets you'd like,upto a maximum of "+
-
- ltostr(available_trys)+",\nand remember each bet is "+itostr(BET)+
-
- " Minutes taken off of your time? ";
-
-
-
- swtch := TRUE ;
-
- while(swtch = TRUE)
-
- {
-
- print(AVATAR_GOTO,(char)5,(char)1,blanks) ; // Print a blank line
-
- print(AVATAR_GOTO,(char)6,(char)1,blanks) ; // Print a blank line
-
- print(AVATAR_GOTO,(char)7,(char)1,blanks) ; // Print a blank line
-
- print(AVATAR_GOTO,(char)5,(char)1 ) ; // set ready for printing
-
- input_str(get_number, INPUT_WORD, 0, 2,prompt);
-
- number := strtoi(get_number) ; // convert string to int
-
- if(number < 1 OR number > available_trys)
-
- prompt := "You must enter a number between 1 and "+ltostr(available_trys)+" ? " ;
-
- else
-
- swtch := FALSE ;
-
- }
-
-
-
- timeadjustsoft(-(number * BET * 60) ) ; // take off bet from users time
-
- print(AVATAR_GOTO,(char)6,(char)1,blanks) ;
-
- print(AVATAR_GOTO,(char)7,(char)1,blanks) ;
-
- print(AVATAR_GOTO,(char)6,(char)1 ) ;
-
- print("You have ",timeleft()," minutes left,after your bet of ",number*BET," minutes.\n") ;
-
- log("-Bet "+itostr((number * BET))+" minutes" ); // Log the bet to logfile
-
-
-
- return number ;
-
- }
-
-
-
- // print out each computer line,then check for any winning numbers
-
- void print_line(array[1..BALLS] of int: balls,int: x)
-
- {
-
- int: y,
-
- matches ;
-
-
-
- matches := 0 ;
-
- // Print out results,pad with spaces to make neat
-
- print(AVATAR_GOTO,(char)(11+x),(char)1,
-
- COL_LRED,"Line ",strpadleft(itostr(x),2,' ')," : ",COL_WHITE) ;
-
-
-
- for(y := 1 ; y < BALLS+1 ; y := y+1)
-
- if(check_for_match(balls[y]) = TRUE)
-
- {
-
- print(COL_GREEN,strpadleft(itostr(balls[y]),4,' '),COL_WHITE) ;
-
- matches := matches + 1 ;
-
- }
-
- else
-
- print(strpadleft(itostr(balls[y]),4,' ')) ;
-
-
-
- // print out results of any matches above 2 numbers
-
- if(matches = 2)
-
- {
-
- print(AVATAR_GOTO,(char)(11+x),(char)40,COL_LCYAN,"You Won ",MATCHED_2," Minutes",COL_WHITE ) ;
-
- minutes_won := minutes_won+MATCHED_2 ;
-
- }
-
- else if(matches = 3)
-
- {
-
- print(AVATAR_GOTO,(char)(11+x),(char)40,COL_LCYAN,"You Won ",MATCHED_3," Minutes",COL_WHITE ) ;
-
- minutes_won := minutes_won+MATCHED_3 ;
-
- }
-
- else if(matches = 4)
-
- {
-
- print(AVATAR_GOTO,(char)(11+x),(char)40,COL_LCYAN,"You Won ",MATCHED_4," Minutes",COL_WHITE ) ;
-
- minutes_won := minutes_won+MATCHED_4 ;
-
- }
-
- else if(matches = 5)
-
- {
-
- print(AVATAR_GOTO,(char)(11+x),(char)40,COL_LCYAN,"You Won ",MATCHED_5," Minutes",COL_WHITE ) ;
-
- minutes_won := minutes_won+MATCHED_5 ;
-
- }
-
- else if(matches = 6)
-
- {
-
- print(AVATAR_GOTO,(char)(11+x),(char)40,COL_LCYAN,"You Won ",MATCHED_6," Minutes",COL_WHITE ) ;
-
- minutes_won := minutes_won+MATCHED_6 ;
-
- }
-
- else
-
- print(AVATAR_GOTO,(char)(11+x),(char)40,"You Have Not Won Anything!" ) ;
-
-
-
- }
-
-
-
- //simple check routine
-
- int check_for_match(int: ball_to_check)
-
- {
-
- int: x,swtch ;
-
-
-
- swtch := FALSE ;
-
-
-
- for(x := 1 ; x < BALLS+1 ; x := x+1)
-
- if(user_balls[x] = ball_to_check)
-
- swtch := TRUE ;
-
-
-
- return swtch ;
-
- }
-
-
-
- // show a very simple help screen
-
- void help()
-
- {
-
- int: x ;
-
-
-
- // you should'nt need to touch this much,unless you choose differnt colours
-
- // for the results etc,but it does use the defines for most things.
-
- // and its only 1 screen long :)
-
-
-
- print(AVATAR_GOTO,(char)5,(char)1,"Do you need instructions [y/N]" ) ;
-
- x := getch() ;
-
- if(x = 'N' or x = 'n' or x =13) // or return key
-
- return ; // if not then lets get back to business
-
-
-
- print(AVATAR_GOTO,(char)5,(char)1 ) ;
-
- print("The object for this game is to gain on-line time,you do this by playing",
-
- "\nthe lottery,with a slight difference,you are gambling your time for ",
-
- "\ntoday,if you lose it all don't worry,you'll be back to normal tomorrow.",
-
- "\n",
-
- "\nYou pick ",BALLS," numbers within the range of 1 to ",RANDOM,
-
- ",and then decide how many",
-
- "\nlines you want the computer to generate,each line costs you ",BET," minutes, ",
-
- "\nand you can have a maximum of ",MAX_LINES," lines. ",
-
- "\nYou can win time back for a match on 2 to ",BALLS," numbers,upto a maximum of ",
-
- "\n",MAX_TIME," minutes.",
-
- "\nWhen you get a matching number it will show up as green eg ",COL_GREEN,"10"
-
- ,COL_WHITE," and any ",
-
- "\ntime won will show up as blue eg ",COL_LCYAN,"15",COL_WHITE,".",
-
- "\n",
-
- "\nThats about it really,if you have problems please,let the sysop know,so ",
-
- "\nI can fix them quickly.",
-
- "\n\nHave Fun. Mark Taylor.",
-
- "\n\nPress A Key"
-
- ) ;
-
-
-
- x := getch() ;
-
- // Clear the screen from just below the title
-
- for(x := 5 ; x < 23 ; x:= x+1)
-
- print(AVATAR_GOTO,(char)x,(char)1,blanks ) ;
-
- }
-
-
-
- // main loop
-
- int main()
-
- {
-
- int: x,lines ;
-
-
-
- log(":Starting Lottery Time Gamble"); // Log the start to logfile
-
- srand(time()); // Seed random generator
-
- blanks := strpad(blanks,term_width(),' ') ; // set a blank line to users screen width
-
- minutes_won := 0 ; // set winnings to zero
-
-
-
-
-
- print_title() ; // print title
-
- help() ; // check if instructions needed
-
- get_user_numbers(); // Get user numbers
-
- lines := get_number_of_trys() ; // get number of lines
-
-
-
- // go through for each line
-
- for(x:= 1 ; x < lines+1 ; x := x+1)
-
- {
-
- pick_numbers(computer_balls) ;
-
- print_line(computer_balls,x) ;
-
- }
-
-
-
- // pretty up screen and print results
-
- // it does seem as though the user comes off worse most times :)
-
- // I expect this could be changed so there is a slight bias in favour os the user,
-
- // but that would take all the fun out of it :)
-
-
-
- print(AVATAR_GOTO,(char)10,(char)40,COL_WHITE " ") ;
-
-
-
- if(minutes_won > MAX_TIME)
-
- minutes_won := MAX_TIME ;
-
-
-
- timeadjustsoft(minutes_won * 60 ) ; // Add any time won to user time,in minutes
-
-
-
- // print(AVATAR_GOTO,(char)22,(char)1,"You added a total of ",minutes_won,
-
- // " minutes to your time,you now have ",timeleft()," minutes") ;
-
- // print(AVATAR_GOTO,(char)23,(char)1,"Please Press A Key") ;
-
-
-
- print(AVATAR_GOTO,(char)(11+lines),(char)1) ; //set cursor to line after all numbers
-
- print("\n\nYou added a total of ",minutes_won," minutes to your time,"
-
- "you now have ",timeleft()," minutes") ;
-
- print("\nPlease Press A Key") ;
-
- x := getch() ;
-
- log("-Gained "+itostr(minutes_won)+" minutes" ); // Log any winnings logfile
-
-
-
-
-
- return 0;
-
- }
-
-
-