home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 030.lha / Ogre / main.c < prev    next >
C/C++ Source or Header  |  1986-11-10  |  3KB  |  126 lines

  1. /*
  2.  *    OGRE - a tactical ground combat game set in 2086.
  3.  *
  4.  *    Written by Michael Caplinger of Rice University 1982
  5.  *    based on the Steve Jackson Microgame (c) 1977.
  6.  *
  7.  *    Ported to Amiga from Unix by Hobie Orris, 1986
  8.  *    (who was too lazy to type in all the comments. Sorry)
  9.  */
  10.  
  11. #define MAIN 1
  12. #include "ext.h"
  13.  
  14.  
  15. main(argc, argv)
  16. int argc;
  17. char **argv;
  18. {
  19.    int mark;
  20.  
  21.    /* The original program set a trap here: signal(SIGINT, handler)
  22.     * For Amiga, I've chosen to handle close window events instead
  23.     * of breaks; see Amiga_getchar() in termcap.c - H.O.
  24.     */
  25.  
  26.    init_screen();
  27.    mark = get_mark();
  28.    init_units(mark);
  29.    init_ogre(mark);
  30.    disp_ogre_status(TRUE);
  31.  
  32.    while (1)
  33.    {
  34.       init_round();
  35.  
  36.       /* the Ogre fires */
  37.  
  38.       assign_fire_ogre();
  39.       check_over();
  40.  
  41.       /* player moves and fires */
  42.  
  43.       move_def();
  44.       attack_def();
  45.       check_over();
  46.  
  47.       /* 2nd GEV move */
  48.  
  49.       init_gev2();
  50.       move_def();
  51.  
  52.       /* Ogre moves */
  53.  
  54.       move_ogre();
  55.       check_over();
  56.    }
  57. }
  58.  
  59.  
  60. check_over()
  61. {
  62.    char *message, c;
  63.    int over,i;
  64.    static char drawstring[] =
  65.       "The Ogre self-destructs and destroys the CP. Draw!";
  66.    static char youstring[] = "You win!";
  67.    static char ogrestring[] = "The Ogre wins!";
  68.  
  69.    over = FALSE;
  70.  
  71.    if (unit[0].status == DESTROYED)
  72.    {
  73.       message = &ogrestring[0];
  74.       over = TRUE;
  75.    }
  76.  
  77.    /* if the Ogre is immobilized it is beaten */
  78.  
  79.    else if (ogre.movement == 0 && unit[0].range_to_ogre < 5)
  80.    {
  81.       /*
  82.        * Optional rule 8.05 - the Ogre can self-destruct, destroying
  83.        * everything within 4 hexes, and armor at 5 hexes is disabled.
  84.        * So, if CP is within 4 hexes, blow up - H.O.
  85.        */
  86.  
  87.          for (i = 0; i < n_units; ++i)
  88.          {
  89.             if (unit[i].range_to_ogre < 5)
  90.             {
  91.                unit[i].status = DESTROYED;
  92.                disp_unit(i);
  93.              }
  94.              else if (unit[i].range_to_ogre == 5 && unit[i].status == OK &&
  95.                 unit[i].type != CP && unit[i].type != INFANTRY)
  96.              {
  97.                unit[i].status = DISABLED;
  98.                disp_unit(i);
  99.             }
  100.          }
  101.          disp_hex(ogre.l_hex, ogre.r_hex, '*');
  102.          message = &drawstring[0];
  103.          over = TRUE;
  104.       }
  105.       else if (ogre.movement == 0 && unit[0].range_to_ogre > 4)
  106.       {
  107.          message = &youstring[0];
  108.          over = TRUE;
  109.       }
  110.  
  111.    if (over)
  112.    {
  113.       puts(message);
  114.       for (i = 16; i < 23; ++i)
  115.       {
  116.          movecur(i,1);
  117.          eeol(i);
  118.       }
  119.       eeol(16);
  120.       movecur(16,1);
  121.       Amiga_puts(message);
  122.       c = Amiga_getchar();
  123.       reset_term();
  124.    }
  125. }
  126.