home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / language / grs / g / m3 < prev    next >
Encoding:
Text File  |  1991-04-05  |  891 b   |  58 lines

  1. integer function somebody_has_won()
  2. {
  3. integer germans, americans;
  4.  
  5.    germans := 0;
  6.    americans := 0;
  7.  
  8.    foreach i in tank.get_instances() do
  9.    {
  10.       if i.get_pos("German")=-1 then
  11.          germans := germans + 1;
  12.       else
  13.          americans := americans + 1;
  14.       endif;
  15.    };
  16.  
  17.    if americans=0 then
  18.       write("\n\nThe Germans have won!\n\n");
  19.       return(true);
  20.    else
  21.       if germans=0 then
  22.          write("\n\nThe Americans have won!\n\n");
  23.          return(true);
  24.       else
  25.          return(false);
  26.       endif;
  27.    endif;
  28. };
  29.  
  30. null function go()
  31. {
  32.    cls();
  33.  
  34.    foreach i in tank.get_instances() do
  35.    {
  36.       i.display();
  37.    };
  38.  
  39.    loop
  40.       foreach i in tank.get_instances() do
  41.       {
  42.          i.move();
  43.       };
  44.  
  45.       cls();
  46.  
  47.       foreach i in tank.get_instances() do
  48.       {
  49.          i.display();
  50.       };
  51.  
  52.       exiton( somebody_has_won() );
  53.  
  54.    endloop;
  55. };
  56.  
  57. go();
  58.