home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3431 / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-28  |  3.3 KB  |  137 lines

  1. /*LINTLIBRARY*/
  2.  
  3. /*
  4.  * Copyright (C) 1991 by Jay Konigsberg. mail: jak@sactoh0
  5.  *
  6.  * Permission to use, copy, modify, and distribute this  software  and  its
  7.  * documentation is hereby  granted,  provided  that  the  above  copyright
  8.  * notice appear in all copies  and that  both  the  copyright  notice  and
  9.  * this permission notice appear in supporting documentation. This software
  10.  * is provided "as is" without express or implied  warranty.  However,  the
  11.  * author retains all Copyright priviliges and rights  to  renumeration  if
  12.  * this software is sold.
  13.  *
  14.  * Also, and very important. This game is for recrecation ONLY and is NOT
  15.  * to be used for gambling in any way. 
  16.  */
  17.  
  18. /*
  19.  * main for "video_poker" - just like the ones in Nevada.
  20.  * Jay Konigsberg
  21.  * jak@sactoh0 - pacbel!sactoh0!jak
  22.  */
  23.  
  24. #include    "vid_local.h"
  25. #include    <signal.h>
  26. #include    "vid_curses.h"
  27. #include    "vid_poker.h"
  28.  
  29. int        bet,
  30.         credits;
  31.  
  32. void    main()
  33. {
  34. int    deck[10],    /* The random numbers as they were generated    */
  35.     value[10],    /* The card values - A, 2 ... 12=Q, 13=K    */
  36.     s_value[10],    /* Sorted card values - A, 2 ... 12=Q, 13=K    */
  37.     loop,        /* loop while bet is selected            */
  38.     suite[10],    /* Spades=0, Hearts=1, Clubs=2, Diamonds=3    */
  39.     s_suite[10];    /* sorted suites                */
  40. int    cardinx;    /* Just a loop variable                */
  41.  
  42. credits=0;
  43. rawmode();        /* set up char-at-a-time processing        */
  44. signal(SIGINT, cleanup);/* trap inturrepts (also in rawmode)        */
  45.  
  46. initscr();
  47. payoff_val(0);        /* Put the payoff values on the screen */
  48.  
  49. for (cardinx=0; cardinx < 5; ++cardinx)
  50.     draw_back(cardinx);
  51.  
  52. for (;;)
  53.     {
  54.     for (cardinx=0; cardinx<10; ++cardinx)
  55.     {
  56.     deck[cardinx] = 0;
  57.     value[cardinx] = 0;
  58.     s_value[cardinx] = 0;
  59.     suite[cardinx] = 0;
  60.     s_suite[cardinx] = 0;
  61.     }
  62.  
  63.     bet = 0;
  64.     loop = TRUE;
  65.     while (loop)
  66.     {
  67.     mvaddstr(21,0,"B/b=bet, M/m=max bet, D/d/Retrun=Draw, R/r=Refresh, Q/q=quit?   ");
  68.     move(21,62);
  69.     refresh();
  70.     switch (getch())
  71.         {
  72.         case '\n':
  73.         case '\r':
  74.         case  'D':
  75.         case  'd':
  76.         loop=FALSE;
  77.         break;
  78.         case 'q':
  79.         case 'Q':
  80.         case 'n':
  81.         case 'N':
  82.         loop=FALSE;
  83.         cleanup();
  84.         break;
  85.         case 'M':
  86.         case 'm':
  87.         case ' ':
  88.         loop=FALSE;
  89.         credits -= (5 - bet);
  90.         bet = 5;
  91.         for (cardinx=0; cardinx < 5; ++cardinx)
  92.             draw_back(cardinx);
  93.         sleep(1);
  94.         mvprintw(21, 65, "Bet     %-6d", bet);
  95.         mvaddstr( 9, 29, "               ");
  96.         mvaddstr(19, 0, "\t\t\t\t\t\t\t\t\t\t");
  97.         payoff_val(bet); /* Put the payoff values on the screen */
  98.         break;
  99.         case 'b':
  100.         case 'B':
  101.         ++bet;
  102.         if ( bet == 5 )
  103.             loop=FALSE;
  104.         else
  105.             loop=TRUE;
  106.         mvaddstr( 9, 29, "               ");
  107.         mvaddstr(19, 0, "\t\t\t\t\t\t\t\t\t\t");
  108.         for (cardinx=0; cardinx < 5; ++cardinx)
  109.             draw_back(cardinx);
  110.         payoff_val(bet); /* Put the payoff values on the screen */
  111.         mvprintw(21, 65, "Bet     %-6d", bet);
  112.         --credits;
  113.         break;
  114.         case 'R':
  115.         case 'r':
  116.         clearok(stdscr, TRUE);
  117.         refresh();
  118.         break;
  119.         }
  120.  
  121.     mvprintw(22, 65, "Credits %-5d    ", credits);
  122.     mvaddstr(23, 65, "                ");
  123.     refresh();;
  124.     if (bet == 0)
  125.         loop=TRUE;
  126.     }
  127.     deal(deck, 5);
  128.     setup_deck(deck, value, suite, 5);
  129.     setup_deck(deck, s_value, s_suite, 5);
  130.     sort(s_value, s_suite, 5);
  131.     display_hand(value, suite, 5);
  132.     (void)display_val(id_hand(s_value, s_suite));
  133.     draw(deck, value, suite);
  134.     }
  135. /*NOTREACHED*/
  136. }
  137.