home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 528.lha / YatZ_v1.0 / src / yatz.c < prev    next >
C/C++ Source or Header  |  1991-07-02  |  16KB  |  713 lines

  1. /*
  2.   Auto: ram:cc   -3 <path><file> +l
  3.   Auto: ram:ln  <path><file>.o -lc +lcdb <path>sound.o -lc16
  4.  */
  5. #include <exec/types.h>
  6. #include <intuition/intuition.h>
  7. #include <libraries/dos.h>
  8. #define DICE 0x30
  9. #define CLOSED 1
  10. #define ROLL 0x40
  11. #define SCORE 3
  12. #define THREEOFAKIND 9
  13. #define FOUROFAKIND 10
  14. #define FULLHOUSE 11
  15. #define SMSTRAIGHT 12
  16. #define LGSTRAIGHT 13
  17. #define YATZ 14
  18. #define CHANCE 15
  19. #define SOME 20
  20. #define NONE 21
  21. #define BONUS 19
  22. #define TOTALLEFT 18
  23. #define INTUITION_REV 33
  24. #define GRAPHICS_REV 33
  25. #include <dh2:aztec/progs/yatz/yatz.h>        /* make sure this path is */
  26.                                               /* set right!             */
  27. struct IntuitionBase *IntuitionBase = NULL;
  28. struct GfxBase *GfxBase = NULL;
  29. struct Window  *window1 = NULL;
  30. struct RastPort *rp;
  31. char            diepic[6][3][3] =
  32. {"   ",
  33.  " o ",
  34.  "   ",
  35.  
  36.  "o  ",
  37.  "   ",
  38.  "  o",
  39.  
  40.  "o  ",
  41.  " o ",
  42.  "  o",
  43.  
  44.  "o o",
  45.  "   ",
  46.  "o o",
  47.  
  48.  "o o",
  49.  " o ",
  50.  "o o",
  51.  
  52.  "o o",
  53.  "o o",
  54.  "o o"};
  55. LONG            seed;
  56. USHORT          FINISHFLAG = 0;
  57. int             GadFlag = 0;
  58. char           *grandstr;
  59. int             diceroll[6];
  60. int             highscore;
  61. USHORT          leaveprog = FALSE;
  62. int             rollcount = 0;
  63. USHORT             havesound = TRUE;
  64. int             scores[20] =
  65. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  66. short           scoretable[15] =
  67. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  68. int             dicegad[6] =
  69. {0, 0, 0, 0, 0, 0};
  70.  
  71. VOID 
  72. cleanExit(wind, returnValue)
  73.     struct Window  *wind;
  74.     int             returnValue;
  75. {
  76.     if (havesound)
  77.      cleanup();
  78.     if (wind)
  79.     CloseWindow(wind);
  80.     if (GfxBase)
  81.     CloseLibrary((struct Library *) GfxBase);
  82.     if (IntuitionBase)
  83.     CloseLibrary((struct Library *) IntuitionBase);
  84.     exit(returnValue);
  85. }
  86.  
  87.  
  88. VOID 
  89. OpenAll(VOID)
  90. {
  91.     int             hs;
  92.     IntuitionBase = (struct IntuitionBase *)
  93.     OpenLibrary("intuition.library", INTUITION_REV);
  94.     if (IntuitionBase == NULL)
  95.     cleanExit(NULL, RETURN_WARN);
  96.     GfxBase = (struct GfxBase *)
  97.     OpenLibrary("graphics.library", GRAPHICS_REV);
  98.  
  99.     if (GfxBase == NULL)
  100.     cleanExit(NULL, RETURN_WARN);
  101.  
  102.     window1 = (struct Window *) OpenWindow(&NewWindowStructure1);
  103.     if (window1 == NULL)
  104.     cleanExit(NULL, RETURN_WARN);
  105.     if ((hs = fopen("yatz.hs", "r")) != NULL) {
  106.     fscanf(hs, "%d", &highscore);
  107.     fclose(hs);
  108.     } else {
  109.     if ((hs = fopen("yatz.hs", "w")) != NULL) {
  110.         highscore = 0;
  111.         fprintf(hs, "%d", highscore);
  112.         fclose(hs);
  113.     }
  114.     }
  115.      if (loadSound("diceroll") == 20)
  116.             havesound = FALSE;
  117. }
  118.  
  119. VOID 
  120. ShowHighScore()
  121. {
  122.     Move(rp, 352, 145);
  123.     SetDrMd(rp, JAM2);
  124.     if (highscore < 10)
  125.     sprintf(grandstr, "  %d", highscore);
  126.     else if (highscore < 100)
  127.     sprintf(grandstr, " %d", highscore);
  128.     else
  129.     sprintf(grandstr, "%d", highscore);
  130.     Text(rp, grandstr, 3);
  131. }
  132.  
  133. VOID 
  134. RollAllDice()
  135. {
  136.     int             counter;
  137.     for (counter = 1; counter < 6; counter++)
  138.     diceroll[counter] = RollDie(counter);
  139.     if (havesound == TRUE)
  140.         soundSound();
  141. }
  142.  
  143.  
  144. int 
  145. RollDie(diepos)
  146.     USHORT          diepos;
  147. {
  148.     int             die;
  149.     die = rand();
  150.     die = die / 5462;
  151.     die++;
  152.     SetDrMd(rp, JAM2);
  153.     Move(rp, 22, (28 * diepos) - 6);
  154.     Text(rp, &diepic[die - 1][0], 3);
  155.     Move(rp, 22, (28 * diepos) + 1);
  156.     Text(rp, &diepic[die - 1][1], 3);
  157.     Move(rp, 22, (28 * diepos) + 8);
  158.     Text(rp, &diepic[die - 1][2], 3);
  159.  
  160.     return die;
  161. }
  162.  
  163. VOID 
  164. UnGhostDice()
  165. {
  166.     OnGadget(&Gadget8, window1, NULL);
  167.     OnGadget(&Gadget9, window1, NULL);
  168.     OnGadget(&Gadget10, window1, NULL);
  169.     OnGadget(&Gadget11, window1, NULL);
  170.     OnGadget(&Gadget12, window1, NULL);
  171.     SetDrMd(rp, JAM2 | INVERSVID);
  172.     RectFill(rp, 15, 15, 54, 150);
  173.     RefreshGList(&Gadget8, window1, NULL, 5);
  174. }
  175.  
  176. VOID 
  177. GhostDice()
  178. {
  179.     OffGadget(&Gadget8, window1, NULL);
  180.     OffGadget(&Gadget9, window1, NULL);
  181.     OffGadget(&Gadget10, window1, NULL);
  182.     OffGadget(&Gadget11, window1, NULL);
  183.     OffGadget(&Gadget12, window1, NULL);
  184. }
  185.  
  186. SHORT 
  187. RollSelected()
  188. {
  189.     int             counter;
  190.     int             status = NONE;
  191.     for (counter = 1; counter < 6; counter++)
  192.     if (dicegad[counter] == 1) {
  193.         dicegad[counter] = 0;
  194.         switch (counter) {
  195.         case 1:
  196.         RefreshGList(&Gadget8, window1, NULL, 1);
  197.         Gadget8.Flags = NULL;
  198.         status = SOME;
  199.         break;
  200.         case 2:
  201.         RefreshGList(&Gadget9, window1, NULL, 1);
  202.         Gadget9.Flags = NULL;
  203.         status = SOME;
  204.         break;
  205.         case 3:
  206.         RefreshGList(&Gadget10, window1, NULL, 1);
  207.         Gadget10.Flags = NULL;
  208.         status = SOME;
  209.         break;
  210.         case 4:
  211.         RefreshGList(&Gadget11, window1, NULL, 1);
  212.         Gadget11.Flags = NULL;
  213.         status = SOME;
  214.         break;
  215.         case 5:
  216.         RefreshGList(&Gadget12, window1, NULL, 1);
  217.         Gadget12.Flags = NULL;
  218.         status = SOME;
  219.         break;
  220.         }
  221.         diceroll[counter] = RollDie(counter);
  222.     }
  223.     if ((rollcount == 1) && (status == SOME))
  224.          GhostDice();
  225.     if ( (status == SOME) && (havesound == TRUE) )
  226.     soundSound();
  227.     return status;
  228.  
  229. }
  230.  
  231. USHORT 
  232. handleIDCMP(struct Window * win)
  233. {
  234.     int             flag = 0;
  235.     struct IntuiMessage *message = NULL;
  236.     int             code;
  237.     USHORT          id;
  238.     int             dicenum;
  239.     ULONG           class;
  240.     struct Gadget  *g;
  241.     while (message = (struct IntuiMessage *) GetMsg(win->UserPort)) {
  242.     class = message->Class;
  243.     code = message->Code;
  244.     g = (struct Gadget *) (message->IAddress);
  245.     ReplyMsg((struct Message *) message);
  246.     switch (class) {
  247.     case CLOSEWINDOW:
  248.         flag = CLOSED;
  249.         break;
  250.     case GADGETDOWN:
  251.         id = g->GadgetID;
  252.         dicenum = id - DICE;
  253.         dicenum++;
  254.         if ((dicegad[dicenum]) == 1)
  255.         dicegad[dicenum] = 0;
  256.         else
  257.         dicegad[dicenum] = 1;
  258.         break;
  259.     case GADGETUP:
  260.         flag = g->GadgetID;
  261.         break;
  262.     }
  263.     }
  264.     return (flag);
  265. }
  266.  
  267. VOID 
  268. DoDigits()
  269. {
  270.     int             digit, counter;
  271.     char           *temp;
  272.     digit = GadFlag - 2;
  273.     scores[digit] = 0;
  274.     for (counter = 1; counter < 6; counter++)
  275.     if (diceroll[counter] == digit)
  276.         scores[digit]++;
  277.     scores[digit] = scores[digit] * digit;
  278.     Move(rp, 198, 11 + (14 * digit));
  279.     if (scores[digit] < 10)
  280.     sprintf(temp, " %d", scores[digit]);
  281.     else
  282.     sprintf(temp, "%d", scores[digit]);
  283.     Text(rp, temp, 2);
  284. }
  285.  
  286. USHORT 
  287. NumLeftBlanks()
  288. {
  289.     USHORT          counter, blanks = 6;
  290.     for (counter = 0; counter < 7; counter++)
  291.     if (scoretable[counter] == 1)
  292.         blanks--;
  293.     return blanks;
  294. }
  295.  
  296. USHORT 
  297. NumRightBlanks()
  298. {
  299.     USHORT          counter, blanks = 7;
  300.     for (counter = 7; counter < 16; counter++)
  301.     if (scoretable[counter] == 1)
  302.         blanks--;
  303.     return blanks;
  304. }
  305.  
  306. int 
  307. DoBonus()
  308. {
  309.     char           *temp;
  310.     int             total = 0;
  311.     USHORT          counter;
  312.     for (counter = 0; counter < 7; counter++)
  313.     total = total + scores[counter];
  314.     return total;
  315. }
  316.  
  317. VOID 
  318. DoGrand()
  319. {
  320.     int             hs;
  321.     USHORT          counter, totals = 0;
  322.     if ((NumLeftBlanks() == 0) && NumRightBlanks() == 0) {
  323.     FINISHFLAG = 1;
  324.     for (counter = 7; counter < 15; counter++)
  325.         totals = totals + scores[counter];
  326.     totals = totals + scores[TOTALLEFT];
  327.     totals = totals + scores[BONUS];
  328.     sprintf(grandstr, "%u", totals);
  329.     if (totals < 100)
  330.         sprintf(grandstr, " %u", totals);
  331.     Move(rp, 352, 132);
  332.     Text(rp, grandstr, 3);
  333.     if (totals > highscore)
  334.         if ((hs = fopen("yatz.hs", "w")) != NULL) {
  335.         highscore = totals;
  336.         fprintf(hs, "%d", highscore);
  337.         fclose(hs);
  338.         ShowHighScore();
  339.         }
  340.     }
  341. }
  342.  
  343. VOID 
  344. DoneRolls()
  345. {
  346.     USHORT counter;
  347.     ULONG           signalmask, signals;
  348.     signalmask = 1L << window1->UserPort->mp_SigBit;
  349.     DoGrand();
  350.     for (counter = 1; counter < 6; counter++)
  351.     dicegad[counter] = 0;
  352.     Gadget8.Flags = NULL;
  353.     Gadget9.Flags = NULL;
  354.     Gadget10.Flags = NULL;
  355.     Gadget11.Flags = NULL;
  356.     Gadget12.Flags = NULL;
  357.     SetDrMd(rp, JAM2 | INVERSVID);
  358.     RectFill(rp, 15, 15, 54, 150);
  359.     RefreshGList(&Gadget8, window1, NULL, 5);    /* Get Rid of Dice */
  360.     GhostDice();
  361.     if (FINISHFLAG != 1) {
  362.     while ((GadFlag != ROLL) && (GadFlag != CLOSED)) {
  363.         signals = Wait(signalmask);
  364.         if (signals & signalmask)
  365.         GadFlag = handleIDCMP(window1);
  366.     }
  367.     if (GadFlag != CLOSED) {
  368.         UnGhostDice();
  369.         RollAllDice();
  370.     }
  371.     }
  372. }
  373.  
  374. USHORT 
  375. CheckThree()
  376. {
  377.     char           *tempstr;
  378.     USHORT          result = 0, counter, total = 0, temp[7] =
  379.     {0, 0, 0, 0, 0, 0, 0};
  380.     for (counter = 1; counter < 6; counter++) {
  381.     temp[diceroll[counter] - 1]++;
  382.     total = total + diceroll[counter];
  383.     }
  384.  
  385.     for (counter = 0; counter < 6; counter++)
  386.     if (temp[counter] >= 3)
  387.         result = 1;
  388.     if (result != 1)
  389.     total = 0;
  390.     if (GadFlag != FULLHOUSE) {
  391.     scores[GadFlag - 2] = total;
  392.     Move(rp, 360, 25);
  393.     if (total < 10)
  394.         sprintf(tempstr, " %u", total);
  395.     else
  396.         sprintf(tempstr, "%u", total);
  397.     Text(rp, tempstr, 2);
  398.     }
  399.     return result;
  400. }
  401.  
  402.  
  403. USHORT 
  404. CheckFour()
  405. {
  406.     char           *tempstr;
  407.     USHORT          result = 0, counter, total = 0, temp[7] =
  408.     {0, 0, 0, 0, 0, 0, 0};
  409.     for (counter = 1; counter < 6; counter++) {
  410.     temp[diceroll[counter] - 1]++;
  411.     total = total + diceroll[counter];
  412.     }
  413.  
  414.     for (counter = 0; counter < 6; counter++)
  415.     if (temp[counter] >= 4)
  416.         result = 1;
  417.  
  418.     if (result != 1)
  419.     total = 0;
  420.     scores[GadFlag - 2] = total;
  421.     Move(rp, 360, 39);
  422.     if (total < 10)
  423.     sprintf(tempstr, " %u", total);
  424.     else
  425.     sprintf(tempstr, "%u", total);
  426.     Text(rp, tempstr, 2);
  427.     return result;
  428. }
  429.  
  430. USHORT 
  431. CheckFullHouse()
  432. {
  433.     char           *tempstr;
  434.     USHORT          result = 0, counter, temp[7] =
  435.     {0, 0, 0, 0, 0, 0, 0};
  436.     for (counter = 1; counter < 6; counter++)
  437.     temp[diceroll[counter] - 1]++;
  438.  
  439.     for (counter = 0; counter < 6; counter++)
  440.     if (temp[counter] == 2)
  441.         result = 1;
  442.  
  443.     if ((result == 1) && (CheckThree() == 1)) {
  444.     scores[GadFlag - 2] = 25;
  445.     Move(rp, 360, 53);
  446.     Text(rp, "25", 2);
  447.     } else {
  448.     result = 0;
  449.     scores[GadFlag - 2] = 0;
  450.     Move(rp, 360, 53);
  451.     Text(rp, " 0", 2);
  452.     }
  453.     return result;
  454. }
  455.  
  456. USHORT 
  457. CheckSmStraight()
  458. {
  459.     char           *tempstr;
  460.     USHORT          result = 0, counter, total = 0, temp[7] =
  461.     {0, 0, 0, 0, 0, 0, 0};
  462.     for (counter = 1; counter < 6; counter++)
  463.     temp[diceroll[counter] - 1]++;
  464.     total = 0;
  465.     for (counter = 0; counter < 6; counter++) {
  466.     if (temp[counter] >= 1)
  467.         total++;
  468.     else {
  469.         if (temp[counter] == 0)
  470.         total = 0;
  471.     }
  472.     if (total == 4)
  473.         result = 1;
  474.     }
  475.     if (result == 1) {
  476.     scores[GadFlag - 2] = 30;
  477.     Move(rp, 360, 67);
  478.     Text(rp, "30", 2);
  479.     } else {
  480.     scores[GadFlag - 2] = 0;
  481.     Move(rp, 360, 67);
  482.     Text(rp, " 0", 2);
  483.     }
  484.     return result;
  485. }
  486.  
  487. USHORT 
  488. CheckLgStraight()
  489. {
  490.     char           *tempstr;
  491.     USHORT          result = 0, counter, total = 0, temp[7] =
  492.     {0, 0, 0, 0, 0, 0, 0};
  493.     for (counter = 1; counter < 6; counter++)
  494.     temp[diceroll[counter] - 1]++;
  495.     total = 0;
  496.     for (counter = 0; counter < 6; counter++) {
  497.     if (temp[counter] >= 1)
  498.         total++;
  499.     else {
  500.         if (temp[counter] == 0)
  501.         total = 0;
  502.     }
  503.     if (total == 5)
  504.         result = 1;
  505.     }
  506.     if (result == 1) {
  507.     scores[GadFlag - 2] = 40;
  508.     Move(rp, 360, 81);
  509.     Text(rp, "40", 2);
  510.     } else {
  511.     scores[GadFlag - 2] = 0;
  512.     Move(rp, 360, 81);
  513.     Text(rp, " 0", 2);
  514.     }
  515.  
  516.     return result;
  517. }
  518.  
  519. USHORT 
  520. CheckYatz()
  521. {
  522.     char           *tempstr;
  523.     USHORT          result = 0, counter, total = 0, temp[7] =
  524.     {0, 0, 0, 0, 0, 0, 0};
  525.     for (counter = 1; counter < 6; counter++)
  526.     temp[diceroll[counter] - 1]++;
  527.     total = 0;
  528.     for (counter = 0; counter < 6; counter++)
  529.     if (temp[counter] == 5)
  530.         result = 1;
  531.     if (result == 1) {
  532.     scores[GadFlag - 2] = scores[GadFlag - 2] + 50;
  533.     if (scoretable[GadFlag - 2] == 0)
  534.         scores[GadFlag - 2] = 50;
  535.     Move(rp, 352, 95);
  536.     if (scores[GadFlag - 2] == 50)
  537.         Text(rp, " 50", 3);
  538.     else {
  539.         sprintf(tempstr, "%d", scores[GadFlag - 2]);
  540.         Text(rp, tempstr, 3);
  541.     }
  542.     } else if (scores[GadFlag - 2] == 0) {
  543.     Move(rp, 353, 95);
  544.     Text(rp, "  0", 3);
  545.     }
  546.     return result;
  547. }
  548.  
  549. VOID 
  550. DoChance()
  551. {
  552.     char           *tempstr;
  553.     USHORT          counter, total = 0;
  554.     for (counter = 1; counter < 6; counter++)
  555.     total = total + diceroll[counter];
  556.     scores[GadFlag - 2] = total;
  557.     Move(rp, 360, 109);
  558.     if (total < 10)
  559.     sprintf(tempstr, " %u", total);
  560.     else
  561.     sprintf(tempstr, "%u", total);
  562.     Text(rp, tempstr, 2);
  563. }
  564.  
  565.  
  566. VOID 
  567. DoTotal()
  568. {
  569.     USHORT          total;
  570.     char           *tempstr;
  571.     if ((NumLeftBlanks() == 0) && (scores[TOTALLEFT] == 0)) {
  572.     scores[TOTALLEFT] = DoBonus();
  573.  
  574.     if (scores[TOTALLEFT] >= 63) {
  575.         scores[BONUS] = 35;
  576.         Move(rp, 198, 118);
  577.         Text(rp, "35", 2);
  578.     } else {
  579.         Move(rp, 198, 118);
  580.         Text(rp, " 0", 2);
  581.     }
  582.     total = scores[TOTALLEFT];
  583.     Move(rp, 190, 109);
  584.     if (total < 10)
  585.         sprintf(tempstr, "  %u", total);
  586.     else
  587.         sprintf(tempstr, " %u", total);
  588.     Text(rp, tempstr, 3);
  589.     }
  590. }
  591.  
  592.  
  593. VOID 
  594. DoRestart()
  595. {
  596.     ULONG           signalmask, signals;
  597.     int             counter;
  598.     signalmask = 1L << window1->UserPort->mp_SigBit;
  599.     for (counter = 0; counter < 20; counter++)
  600.     scores[counter] = 0;
  601.     for (counter = 0; counter < 15; counter++)
  602.     scoretable[counter] = 0;
  603.     while ((GadFlag != ROLL) && (GadFlag != CLOSED)) {
  604.     signals = Wait(signalmask);
  605.     if (signals & signalmask)
  606.         GadFlag = handleIDCMP(window1);
  607.     }
  608.     if (GadFlag != CLOSED) {
  609.         OnGadget(&Gadget8, window1, NULL);
  610.         OnGadget(&Gadget9, window1, NULL);
  611.         OnGadget(&Gadget10, window1, NULL);
  612.         OnGadget(&Gadget11, window1, NULL);
  613.         OnGadget(&Gadget12, window1, NULL);
  614.         SetDrMd(rp, JAM2 | INVERSVID); 
  615.         RectFill(rp, 1, 10, 375, 150);
  616.         RefreshGList(&Gadget1, window1, NULL, 22);
  617.         ShowHighScore();
  618.     RollAllDice();
  619.     }
  620.      else leaveprog = TRUE;
  621.     FINISHFLAG = 0;
  622. }
  623.  
  624. VOID 
  625. main()
  626. {
  627.     ULONG           signalmask, signals;
  628.     OpenAll();
  629.     seed = time();
  630.     srand((USHORT) seed);
  631.     signalmask = 1L << window1->UserPort->mp_SigBit;
  632.     rp = window1->RPort;
  633.     SetAPen(rp, 1);
  634.     ShowHighScore();
  635.     while ((GadFlag != ROLL) && (GadFlag != CLOSED)) {
  636.     signals = Wait(signalmask);
  637.     if (signals & signalmask)
  638.         GadFlag = handleIDCMP(window1);
  639.     }
  640.     if (GadFlag != CLOSED) {
  641.          UnGhostDice();
  642.      RollAllDice();
  643.          }
  644.        else
  645.         {
  646.         cleanupsome();
  647.         havesound = FALSE;
  648.         }
  649.     
  650.            while (GadFlag != CLOSED) {
  651.         if (FINISHFLAG == 1)
  652.         DoRestart();
  653.             if (leaveprog != TRUE)
  654.           {
  655.         signals = Wait(signalmask);
  656.         if (signals & signalmask)
  657.         GadFlag = handleIDCMP(window1);
  658.         if ((GadFlag == ROLL) && (rollcount < 2)) {
  659.         if (RollSelected() == NONE)
  660.             rollcount--;
  661.         rollcount++;
  662.         } else if ((GadFlag >= SCORE) && (GadFlag <= SCORE + 5) && (scoretable[GadFlag - 2] == 0)) {
  663.         DoDigits();
  664.         scoretable[GadFlag - 2] = 1;
  665.         rollcount = 0;
  666.         DoTotal();
  667.         DoneRolls();
  668.         } else if ((GadFlag == THREEOFAKIND) && (scoretable[GadFlag - 2] == 0)) {
  669.         CheckThree();
  670.         scoretable[GadFlag - 2] = 1;
  671.         rollcount = 0;
  672.         DoneRolls();
  673.         } else if ((GadFlag == FOUROFAKIND) && (scoretable[GadFlag - 2] == 0)) {
  674.         CheckFour();
  675.         scoretable[GadFlag - 2] = 1;
  676.         rollcount = 0;
  677.         DoneRolls();
  678.         } else if ((GadFlag == FULLHOUSE) && (scoretable[GadFlag - 2] == 0)) {
  679.         CheckFullHouse();
  680.         scoretable[GadFlag - 2] = 1;
  681.         rollcount = 0;
  682.         DoneRolls();
  683.         } else if ((GadFlag == SMSTRAIGHT) && (scoretable[GadFlag - 2] == 0)) {
  684.         CheckSmStraight();
  685.         scoretable[GadFlag - 2] = 1;
  686.         rollcount = 0;
  687.         DoneRolls();
  688.         } else if ((GadFlag == LGSTRAIGHT) && (scoretable[GadFlag - 2] == 0)) {
  689.         CheckLgStraight();
  690.         scoretable[GadFlag - 2] = 1;
  691.         rollcount = 0;
  692.         DoneRolls();
  693.         } else if ((GadFlag == YATZ) && ((scoretable[GadFlag - 2] == 0)
  694.                          || (scores[GadFlag - 2] > 0))) {
  695.         if ((CheckYatz() == 1) || (scoretable[GadFlag-2] == 0))
  696.                 {
  697.         scoretable[GadFlag - 2] = 1;
  698.         rollcount = 0;
  699.         DoneRolls();
  700.                 }
  701.         } else {
  702.         if ((GadFlag == CHANCE) && (scoretable[GadFlag - 2] == 0)) {
  703.             scoretable[GadFlag - 2] = 1;
  704.             DoChance();
  705.             rollcount = 0;
  706.             DoneRolls();
  707.         }
  708.         }
  709.          }
  710.     }
  711.     cleanExit(window1, RETURN_OK);
  712. }
  713.