home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / gammon20.zip / GAMMON20.PAS < prev    next >
Pascal/Delphi Source File  |  1990-08-12  |  42KB  |  1,386 lines

  1. {$A+,B-,D+,E+,F-,I+,L+,N-,O+,R+,S+,V-}
  2. {$M 16384,0,655360}
  3.  
  4. {                              Backgammon
  5.                                    by
  6.                                Joel Bergen
  7.  
  8.               Modified from the original WWIV Backgammon written by
  9.                          The Hightailer, sysop of
  10.                          The Rapid Transit System
  11.                          Richmond VA
  12.                                                                             }
  13.  
  14. program gammon;
  15.  
  16. {$I commtag.pas}
  17.  
  18.  
  19. type
  20. gametype = record
  21.   player1name : string[25];
  22.   player2name : string[25];
  23.   sidetomove  : integer;  {1=1's turn,2=2's turn,3=1 won,4=2 won, 5=signup}
  24.   lastmovedate: string[25];              { for sysop }
  25.   totalmoves  : integer;
  26.   lastroll    : string[25];
  27.   lastmove    : array[1..4] of string[25];
  28.   piparray    : array[0..25] of integer;    {1-24 holds # of pips in each slot}
  29. end;                                        {0 = player 2's pips on bar       }
  30.                                             {25 = player 1's pips on bar      }
  31.                                             {player 1's pips are positive values }
  32.                                             {player 2's pips are negative values}
  33.  
  34. var
  35. command : char;
  36. movesleft,offboard1,offboard2,movenumber,frommove,tomove,die1,die2 : integer;
  37. tempdie1,tempdie2,moveflag,pipplace,pipcode,gameposition,setnumber : integer;
  38. toslot,fromslot : array[1..4] of string[25];
  39. bumpcode : array[1..4] of integer;
  40. gamefile : file of gametype;
  41. thisgame : gametype;
  42. takingitoff,moveok,nomove,oktocontinue,player1,player2,oktomove : boolean;
  43. temppause   : boolean;
  44. requestfile : text;
  45.  
  46. procedure Greturn;         { closes current data file }
  47. var                        { restores top-of-screen data}
  48. f : file;                  {returns to BBS }
  49. begin
  50.   close(gamefile);
  51.   return;
  52. end;
  53.  
  54. procedure pauseon;
  55. begin
  56.   temppause := false;
  57. end;
  58.  
  59. procedure pauseoff;
  60. begin
  61. end;
  62.  
  63. procedure resetgame;         {initializes a new game }
  64. var
  65. ctr : integer;
  66. begin
  67.   with thisgame do
  68.     begin
  69.       sidetomove := random(2) + 1;   {side to move 1st determined randomly}
  70.       totalmoves := 0;
  71.       lastroll := '00';
  72.       lastmovedate := 'NEVER';
  73.       lastmove[1] := 'NONE';
  74.       for ctr := 2 to 4 do
  75.         lastmove[ctr] := ' ';
  76.       for ctr := 0 to 25 do
  77.         piparray[ctr] := 0;
  78.       piparray[24] := 2;
  79.       piparray[19] := -5;
  80.       piparray[17] := -3;
  81.       piparray[13] := 5;
  82.       piparray[12] := -5;
  83.       piparray[8] := 3;
  84.       piparray[6] := 5;
  85.       piparray[1] := -2;
  86.     end;
  87. end;
  88.  
  89. procedure initialize;
  90. var
  91. ctr : integer;
  92. begin
  93.   randomize;
  94.   setnumber := 1;        {set number 1 is default}
  95.   assign(gamefile,'gammon1.dat');
  96.   {$I-}  reset(gamefile);  {$I+}
  97.   if ioresult <> 0 then         {create set 1 if not present}
  98.     begin
  99.       print('     Creating first data file...');
  100.       rewrite(gamefile);
  101.       for ctr := 1 to 9 do
  102.         begin
  103.           thisgame.player1name := '';
  104.           thisgame.player2name := '';
  105.           resetgame;
  106.           thisgame.sidetomove:=3;   {this will flag game as available}
  107.           write(gamefile,thisgame);
  108.         end;
  109.       close(gamefile);
  110.     end;
  111.   reset(gamefile);
  112. end;
  113.  
  114. procedure gotobottom;      {move cursor to bottom of screen}
  115. begin
  116.   locate(24,1);
  117.   checkhangup;
  118. end;
  119.  
  120. procedure readgame;       {reads in game data}
  121. begin
  122.   seek(gamefile,gameposition);
  123.   read(gamefile,thisgame);
  124. end;
  125.  
  126. procedure rolldice;          {rolls dice}
  127. begin
  128.   die1 := random(6) + 1;
  129.   die2 := random(6) + 1;
  130.   tempdie1 := die1;
  131.   tempdie2 := die2;
  132. end;
  133.  
  134. procedure initializemove;    {do before each move attempt}
  135. var
  136. ctr,temp : integer;
  137. begin
  138.   for ctr := 1 to 4 do
  139.     begin
  140.       bumpcode[ctr] := 0;
  141.     end;
  142.   die1 := tempdie1;    {use tempdice since user may decide to do move over}
  143.   die2 := tempdie2;
  144.   if die1 = die2 then
  145.     movesleft := 4
  146.   else
  147.     begin
  148.       movesleft := 2;
  149.       if die1 < die2 then
  150.         begin
  151.           temp := die2;     {swap dice}
  152.           die2 := die1;
  153.           die1 := temp;
  154.         end;
  155.     end;
  156.   movenumber := 1;
  157.   nomove := false;
  158.   moveok := false;
  159. end;
  160.  
  161.  
  162.  
  163. procedure getgame;      {displays select-game menu}
  164. var
  165. gamenumber : char;
  166. ctr1,ctr2,spacectr : integer;
  167. begin
  168.   cls;
  169.   oktocontinue := true;
  170.   if okansi then locate(8,31);
  171.   ansic(5);
  172.   prompt('Game set number: ');
  173.   ansic(3);print(cstr(setnumber));
  174.   for ctr1 := 0 to 8 do
  175.     begin
  176.       seek(gamefile,ctr1);
  177.       read(gamefile,thisgame);
  178.       if okansi then locate(ctr1 + 10,11);
  179.       ansic(3);
  180.       prompt(cstr(ctr1 + 1)+':  ');
  181.       if not(okansi) then prompt('['+cstr(thisgame.sidetomove)+'] ');
  182.       spacectr := 25 - length(thisgame.player1name);
  183.       if okansi then
  184.         for ctr2 := 1 to spacectr do                     {centers game titles}
  185.           prompt(' ');
  186.       case thisgame.sidetomove of
  187.         1:ansic(4);                   {set playername colors according to}
  188.         2:ansic(2);                   {who's turn it is to move}
  189.         3:ansic(6);
  190.         4:ansic(2);
  191.       end;
  192.       prompt(thisgame.player1name);
  193.       ansic(5);prompt(' vs ');
  194.       case thisgame.sidetomove of
  195.         1:ansic(3);     {player 1's turn}
  196.         2:ansic(4);     {player 2's turn}
  197.         3:ansic(3);     {player 1 won}
  198.         4:ansic(6);     {player 2 won}
  199.       end;
  200.       prompt(thisgame.player2name);
  201.       if not(okansi) then nl;
  202.     end;
  203.   if okansi then gotobottom
  204.   else nl;
  205.   prt('Which game [1-9,Q=Quit]? ');
  206.   onek(gamenumber,'123456789Q');
  207.   if gamenumber = 'Q' then
  208.     oktocontinue := false
  209.   else
  210.     begin
  211.       gameposition := value(gamenumber) - 1;
  212.       readgame;
  213.     end;
  214. end;
  215.  
  216. procedure asciiintroduction;  {DO NOT remove credits!!!!!!!!}
  217. begin
  218.   cls;nl;
  219.   print('  ** B A C K G A M M O N **');nl;
  220.   print('              by');nl;
  221.   print('         Joel Bergen');nl;nl;
  222.   print('          Thanks to:');nl;
  223.   print('The Hightailer, Jak, Marvin, & Marcus Aurelius');nl;
  224.   print('   for their help and ideas.');nl;nl;nl;nl;
  225.   pausescr;
  226. end;
  227.  
  228. procedure introduction;   { title screen - DO NOT REMOVE CREDITS!!!!!!!!!}
  229. begin
  230.   cls;locate(2,27);ansic(5);
  231.   prompt('╔═╤═╤═╤═╤═╤═╦═╤═╤═╤═╤═╤═╗');
  232.   locate(3,27);
  233.   prompt('║ │ │ │ │ │ ║ │ │ │ │ │ ║');
  234.   locate(4,27);
  235.   prompt('║ │ │ │ │ │ ║ │ │ │ │ │ ║');
  236.   locate(5,27);
  237.   prompt('║ │ │ │ │ │ ║ │ │ │ │ │ ║');
  238.   locate(6,27);
  239.   prompt('╠═╪');ansic(4);prompt('B');ansic(5);prompt('│');ansic(4);prompt('A');
  240.   ansic(5);prompt('│');ansic(4);prompt('C');ansic(5);prompt('│');ansic(4);prompt('K');
  241.   ansic(5);prompt('│');ansic(4);prompt('G');ansic(5);prompt('║');ansic(4);prompt('A');
  242.   ansic(5);prompt('│');ansic(4);prompt('M');
  243.   ansic(5);prompt('│');ansic(4);prompt('M');ansic(5);prompt('│');ansic(4);prompt('O');
  244.   ansic(5);prompt('│');ansic(4);prompt('N');ansic(5);prompt('╪═╣');
  245.   locate(7,27);
  246.   prompt('║ │ │ │ │ │ ║ │ │ │ │ │ ║');
  247.   locate(8,27);
  248.   prompt('║ │ │ │ │ │ ║ │ │ │ │ │ ║');
  249.   locate(9,27);
  250.   prompt('║ │ │ │ │ │ ║ │ │ │ │ │ ║');
  251.   locate(10,27);
  252.   prompt('╚═╧═╧═╧═╧═╧═╩═╧═╧═╧═╧═╧═╝');
  253.   locate(12,38);ansic(3);
  254.   prompt('b y');
  255.   locate(14,35);ansic(2);
  256.   prompt('Joel Bergen');
  257.   locate(16,18);ansic(5);
  258.   prompt('Based off WWIV backgammon by The Hightailer');
  259.   locate(18,18);ansic(1);
  260.   prompt('Thanks to Jak, Marvin, Marcus Aurelius, and');
  261.   locate(20,27);ansic(2);
  262.   prompt('The author of BKGAMMON.BAS');
  263.   gotobottom;
  264.   if hangup then Greturn;
  265.   pausescr;
  266. end;
  267.  
  268. procedure processoffboardpips; {diplays # of pips on bar & off board}
  269. var
  270. ctr : integer;
  271. begin
  272.   locate(9,7);ansic(3);
  273.   if thisgame.piparray[0] < 10 then
  274.     prompt(' ');
  275.   prompt(cstr(thisgame.piparray[0]));
  276.   locate(13,7);ansic(2);
  277.   if thisgame.piparray[25] < 10 then
  278.     prompt(' ');
  279.   prompt(cstr(thisgame.piparray[25]));
  280.   offboard1 := 15;                      {calculate # off board for each user}
  281.   offboard2 := 15;
  282.   for ctr := 1 to 24 do
  283.     begin
  284.       if thisgame.piparray[ctr] > 0 then
  285.         offboard1 := offboard1 - thisgame.piparray[ctr];
  286.       if thisgame.piparray[ctr] < 0 then
  287.         offboard2 := offboard2 - abs(thisgame.piparray[ctr]);
  288.     end;
  289.   offboard1 := offboard1 - thisgame.piparray[25];
  290.   offboard2 := offboard2 - thisgame.piparray[0];
  291.   locate(9,17);ansic(3);
  292.   if offboard2 < 10 then
  293.     prompt(' ');
  294.   prompt(cstr(offboard2));
  295.   locate(13,17);ansic(2);
  296.   if offboard1 < 10 then
  297.     prompt(' ');
  298.   prompt(cstr(offboard1));
  299. end;
  300.  
  301. procedure displaygamestatus;    {displays status line}
  302. var
  303. ctr : integer;
  304. begin
  305.   if cs then         {show last move date for sysop}
  306.     begin
  307.       locate(23,1);ansic(5);
  308.       prompt('Last move on: ');
  309.       case thisgame.sidetomove of
  310.         1:ansic(3);
  311.         2:ansic(2);
  312.         3:ansic(3);
  313.         4:ansic(2);
  314.       end;
  315.       prompt(thisgame.lastmovedate);
  316.     end;
  317.   locate(22,1);ansic(5);
  318.   prompt('Moves '+cstr(thisgame.totalmoves)+' ');
  319.   case thisgame.sidetomove of
  320.     1:ansic(3);
  321.     2:ansic(2);
  322.     3:ansic(3);
  323.     4:ansic(2);
  324.   end;
  325.   prompt('Last Roll '+thisgame.lastroll+' ');
  326.   prompt('Moves');
  327.   for ctr := 1 to 4 do
  328.     begin
  329.       prompt(' ');
  330.       prompt(thisgame.lastmove[ctr]);
  331.     end;
  332. end;
  333.  
  334.  
  335. procedure displayscreen;    {draws game screen}
  336. var
  337. ctrx,ctry,xpos,ypos,pipplayer,numberofpips : integer;
  338. begin
  339.   cls;
  340.   ctrx := 29;
  341.   ansic(5);
  342.   repeat                        {draw vertical lines}
  343.     for ctry := 3 to 19 do
  344.       begin
  345.         locate(ctry,ctrx);
  346.         if (ctrx = 29) or (ctrx = 53) or (ctrx = 77) then
  347.           prompt('║')
  348.         else
  349.           prompt('│');
  350.       end;
  351.     ctrx := ctrx + 4;
  352.   until (ctrx > 77) or hangup;
  353.   locate(1,31);ansic(1);
  354.   prompt('X   W   V   U   T   S   R   Q   P   O   N   M');
  355.   locate(2,29);ansic(5);
  356.   prompt('╔═══╤═══╤═══╤═══╤═══╤═══╦═══╤═══╤═══╤═══╤═══╤═══╗');
  357.   locate(11,29);
  358.   prompt('╠═══╪═══╪═══╪═══╪═══╪═══╬═══╪═══╪═══╪═══╪═══╪═══╣');
  359.   locate(20,29);
  360.   prompt('╚═══╧═══╧═══╧═══╧═══╧═══╩═══╧═══╧═══╧═══╧═══╧═══╝');
  361.   locate(21,31);ansic(1);
  362.   prompt('A   B   C   D   E   F   G   H   I   J   K   L');
  363.   locate(6,12);ansic(3);
  364.   prompt('« »');
  365.   locate(3,1);
  366.   case thisgame.sidetomove of
  367.     1:ansic(3);
  368.     2:ansic(4);                  {set color for name}
  369.     3:ansic(3);
  370.     4:ansic(6);
  371.   end;
  372.   prompt(thisgame.player2name);
  373.   locate(11,5);ansic(1);
  374.   prompt('ON BAR   OFF BOARD [Z]');
  375.   locate(19,1);
  376.   case thisgame.sidetomove of
  377.     1:ansic(4);
  378.     2:ansic(2);                 {set color for name}
  379.     3:ansic(6);
  380.     4:ansic(2);
  381.   end;
  382.   prompt(thisgame.player1name);
  383.   locate(16,12);ansic(2);
  384.   prompt('«═»');
  385.   processoffboardpips;
  386.   ctrx := 24;
  387.   repeat                       {draws pips in top 12 slots}
  388.     if thisgame.piparray[ctrx] <> 0 then
  389.       begin
  390.         if thisgame.piparray[ctrx] > 0 then
  391.           pipplayer := 1
  392.         else
  393.           pipplayer := 2;
  394.         numberofpips := thisgame.piparray[ctrx];
  395.         if numberofpips > 8 then      {if > 8 pips in slot, only draw 8}
  396.           numberofpips := 8;
  397.         if numberofpips < -8 then
  398.           numberofpips := -8;
  399.         for ctry := 1 to abs(numberofpips) do
  400.           begin
  401.             xpos := 3 + ctry - 1;
  402.             ypos := (24 - ctrx) * 4 + 30;
  403.             locate(xpos,ypos);
  404.             ansic(pipplayer + 1);
  405.             if pipplayer = 1 then
  406.               prompt('«═»')
  407.             else
  408.               prompt('« »');
  409.           end;
  410.       end;
  411.     ctrx := ctrx - 1;
  412.   until (ctrx < 13) or hangup;
  413.   for ctrx := 1 to 12 do                {draw pips in bottom 12 slots}
  414.     begin
  415.       if thisgame.piparray[ctrx] <> 0 then
  416.         begin
  417.           if thisgame.piparray[ctrx] > 0 then
  418.             pipplayer := 1
  419.           else
  420.             pipplayer := 2;
  421.           numberofpips := thisgame.piparray[ctrx];
  422.           if numberofpips > 8 then
  423.             numberofpips := 8;               {only draw max of 8 pips in a slot}
  424.           if numberofpips < -8 then
  425.             numberofpips := -8;
  426.           for ctry := 1 to abs(numberofpips) do
  427.             begin
  428.               xpos := 20 - ctry;
  429.               ypos := (ctrx - 1) * 4 + 30;
  430.               locate(xpos,ypos);
  431.               ansic(pipplayer + 1);
  432.               if pipplayer = 1 then
  433.                 prompt('«═»')
  434.               else
  435.                 prompt('« »');
  436.             end;
  437.         end;
  438.     end;
  439.   displaygamestatus;
  440.   gotobottom;
  441.   if hangup then Greturn;
  442. end;
  443.  
  444. procedure asciidisplayscreen;
  445. var
  446. ctr : integer;
  447. begin
  448.   nl;nl;nl;nl;nl;nl;nl;nl;
  449.   offboard1 := 15;offboard2 := 15;
  450.   for ctr := 1 to 24 do
  451.     begin
  452.       if thisgame.piparray[ctr] > 0 then
  453.         offboard1 := offboard1 - thisgame.piparray[ctr];
  454.       if thisgame.piparray[ctr] < 0 then
  455.         offboard2 := offboard2 - abs(thisgame.piparray[ctr]);
  456.     end;
  457.   offboard1 := offboard1 - thisgame.piparray[25];
  458.   offboard2 := offboard2 - thisgame.piparray[0];
  459.   print('[-]  '+thisgame.player2name);
  460.   print('ON BAR: '+cstr(thisgame.piparray[0])+'  OFF BOARD [Z]: '+cstr(offboard2));
  461.   nl;print(' X  W  V  U  T  S   R  Q  P  O  N  M');
  462.   print('+--+--+--+--+--+--++--+--+--+--+--+--++');
  463.   prompt('|');ctr := 24;
  464.   repeat
  465.     case thisgame.piparray[ctr] of
  466.       0       :prompt('   ');
  467.       1..9    :prompt(' '+cstr(thisgame.piparray[ctr])+' ');
  468.       10..15  :prompt(cstr(thisgame.piparray[ctr])+' ');
  469.       -15..-10:prompt(cstr(thisgame.piparray[ctr]));
  470.       -9..-1  :prompt(cstr(thisgame.piparray[ctr])+' ');
  471.     end;
  472.     ctr := ctr - 1;
  473.   until (ctr = 18) or hangup;
  474.   prompt('|');ctr := 18;
  475.   repeat
  476.     case thisgame.piparray[ctr] of
  477.       0       :prompt('   ');
  478.       1..9    :prompt(' '+cstr(thisgame.piparray[ctr])+' ');
  479.       10..15  :prompt(cstr(thisgame.piparray[ctr])+' ');
  480.       -15..-10:prompt(cstr(thisgame.piparray[ctr]));
  481.       -9..-1  :prompt(cstr(thisgame.piparray[ctr])+' ');
  482.     end;
  483.     ctr := ctr - 1;
  484.   until (ctr = 12) or hangup;
  485.   print('|');print('|--+--+--+--+--+--++--+--+--+--+--+--+|');
  486.   prompt('|');
  487.   for ctr := 1 to 6 do
  488.     case thisgame.piparray[ctr] of
  489.       0       :prompt('   ');
  490.       1..9    :prompt(' '+cstr(thisgame.piparray[ctr])+' ');
  491.       10..15  :prompt(cstr(thisgame.piparray[ctr])+' ');
  492.       -15..-10:prompt(cstr(thisgame.piparray[ctr]));
  493.       -9..-1  :prompt(cstr(thisgame.piparray[ctr])+' ');
  494.     end;
  495.   prompt('|');
  496.   for ctr := 7 to 12 do
  497.     case thisgame.piparray[ctr] of
  498.       0       :prompt('   ');
  499.       1..9    :prompt(' '+cstr(thisgame.piparray[ctr])+' ');
  500.       10..15  :prompt(cstr(thisgame.piparray[ctr])+' ');
  501.       -15..-10:prompt(cstr(thisgame.piparray[ctr]));
  502.       -9..-1  :prompt(cstr(thisgame.piparray[ctr])+' ');
  503.     end;
  504.   print('|');print('+--+--+--+--+--+--++--+--+--+--+--+--++');
  505.   print(' A  B  C  D  E  F   G  H  I  J  K  L');nl;
  506.   print('[+]  '+thisgame.player1name);
  507.   print('ON BAR: '+cstr(thisgame.piparray[25])+'  OFF BOARD [Z]: '+cstr(offboard1));
  508.   nl;
  509.   print('TOTAL MOVES: '+cstr(thisgame.totalmoves));
  510.   case thisgame.sidetomove of
  511.     1:prompt('[-]');
  512.     2:prompt('[+]');
  513.     3:prompt('[+]');
  514.     4:prompt('[-]');
  515.   end;
  516.   prompt(' LR: '+thisgame.lastroll+' LM:');
  517.   for ctr := 1 to 4 do
  518.     prompt(' '+thisgame.lastmove[ctr]);
  519.   nl;
  520.   if cs then print('Last move on: '+thisgame.lastmovedate);nl;
  521. end;
  522.  
  523. procedure badmove;      {informs user of invalid move}
  524. begin
  525.   prompt(#7);
  526.   if okansi then
  527.     begin
  528.       gotobottom;ansic(6);prompt('Invalid move - try again.     ');
  529.       ansic(1);prompt('                       Re-display screen? ');
  530.       if yn then
  531.         displayscreen
  532.       else
  533.         begin
  534.           gotobottom;
  535.           prompt('                                                                          ');
  536.           gotobottom;
  537.         end;
  538.       ansic(thisgame.sidetomove + 1);
  539.       prompt('Your roll is: '+cstr(die1));   {re-display roll}
  540.       if movesleft > 1 then
  541.         prompt(' '+cstr(die2));
  542.     end
  543.   else
  544.     begin
  545.       print('Invalid move - try again.');
  546.       pausescr;
  547.       asciidisplayscreen;
  548.       prompt('Your roll is: '+cstr(die1));
  549.       if movesleft > 1 then
  550.         print(' '+cstr(die2));
  551.     end;
  552. end;
  553.  
  554. procedure buildgame;   {sysop build procedure}
  555. begin
  556.   nl;nl;
  557.   prt('Edit game, are you sure?');
  558.   if yn then
  559.     begin
  560.       nl;print('If you just want to erase the game,');
  561.       print('just press ENTER when asked for the player names.');
  562.       nl;print('Otherwise, make sure you spell the player names correctly,');
  563.       print('and that you capitalize the names correctly');
  564.       nl;
  565.       prompt('Enter player 1''s name:');
  566.       input(thisgame.player1name,25);
  567.       nl;
  568.       prompt('Enter player 2''s name:');
  569.       input(thisgame.player2name,25);
  570.       prompt('Reset the game? ');
  571.       if yn then resetgame;
  572.       thisgame.sidetomove:=4;
  573.       seek(gamefile,gameposition);
  574.       write(gamefile,thisgame);
  575.       nl;print('Done.');
  576.     end
  577.   else
  578.     begin
  579.       nl;print('Aborted.');
  580.     end;
  581.   nl;pausescr;
  582. end;
  583.  
  584. procedure checkformoveaccess;   {check for player's access to game when "M" selected}
  585. var
  586. errorcode : integer;    {0=OK,1=not in game,2=not your move,3=you won,4=you lost}
  587. begin
  588.   oktomove := false;
  589.   player1 := false;
  590.   player2 := false;
  591.   errorcode := 0;
  592.   if thisuser.name = thisgame.player1name then   {check if user is in this game}
  593.     player1 := true;
  594.   if thisuser.name = thisgame.player2name then
  595.     player2 := true;
  596.   if not(player1) and not(player2) then
  597.     errorcode := 1;
  598.   if errorcode = 0 then           {if user in game, check if it's his move}
  599.     begin
  600.       if player1 then
  601.         case thisgame.sidetomove of
  602.           2:errorcode := 2;
  603.           3:errorcode := 3;
  604.           4:errorcode := 4;
  605.           5:errorcode := 5;
  606.         end
  607.       else
  608.         case thisgame.sidetomove of
  609.           1:errorcode := 2;
  610.           3:errorcode := 4;
  611.           4:errorcode := 3;
  612.           5:errorcode := 5;
  613.         end;
  614.     end;
  615.   if errorcode > 0 then
  616.     begin
  617.       cls;
  618.       if okansi then
  619.         begin
  620.           locate(12,10);ansic(5);      {display error messages}
  621.         end;
  622.       case errorcode of
  623.         1:print('Nice try, but you''re not playing in this game.');
  624.         2:print('It''s still your opponent''s turn to move...');
  625.         3:print('You''ve already won this game!');
  626.         4:print('The game is over, and you lost (hahahaha!)');
  627.         5:print('This game hasn''t started yet!');
  628.       end;
  629.       if okansi then gotobottom else nl;
  630.       pausescr;
  631.     end
  632.   else
  633.     oktomove := true;     {Ok for user to move...}
  634. end;
  635.  
  636. procedure changeset;
  637. var
  638. setchoice : char;
  639. ctr : integer;
  640. begin
  641.   cls;nl;ansic(5);
  642.   prompt('Current game set is: ');
  643.   ansic(1);prompt(cstr(setnumber));
  644.   nl;prt('Enter desired game set number (1 or 2,Q=Quit): ');
  645.   onek(setchoice,'12Q');nl;
  646.   if setchoice = 'Q' then
  647.     begin
  648.       ansic(1);
  649.       prompt('Aborted.');
  650.     end
  651.   else
  652.     begin
  653.       close(gamefile);
  654.       case setchoice of
  655.         '1':begin
  656.               assign(gamefile,'gammon1.dat');
  657.               setnumber := 1;
  658.             end;
  659.         '2':begin
  660.               assign(gamefile,'gammon2.dat');
  661.               {$I-} reset(gamefile); {$I+}
  662.               if ioresult <> 0 then
  663.                 begin
  664.                   nl;print('Creating second data file...');
  665.                   rewrite(gamefile);
  666.                   for ctr := 1 to 9 do
  667.                     begin
  668.                       thisgame.player1name := '';
  669.                       thisgame.player2name := '';
  670.                       resetgame;
  671.                       write(gamefile,thisgame);
  672.                     end;
  673.                   close(gamefile);
  674.                 end;
  675.               setnumber := 2;
  676.             end;
  677.       end;
  678.       reset(gamefile);
  679.       ansic(5);
  680.       prompt('Current game set is now: ');
  681.       ansic(1);prompt(cstr(setnumber));
  682.     end;
  683.   nl;pausescr;
  684. end;
  685.  
  686. procedure movepips;   {moves pips on board when player moves}
  687. var
  688. temp,numberofpips,pipplayer,xpos,ypos : integer;
  689. begin
  690.   if thisgame.piparray[pipplace] < 0 then
  691.     pipplayer := 2
  692.   else
  693.     pipplayer := 1;
  694.   numberofpips := thisgame.piparray[pipplace];
  695.   if numberofpips > 8 then
  696.     numberofpips := 8;
  697.   if numberofpips < -8 then
  698.     numberofpips := -8;
  699.   if pipplace < 13 then
  700.     begin
  701.       xpos := (pipplace - 1) * 4 + 30;
  702.       if pipplace = frommove then
  703.         temp := 1
  704.       else
  705.         temp := 0;
  706.       ypos := 20 - abs(numberofpips) - temp;
  707.     end
  708.   else
  709.     begin
  710.       xpos := (24 - pipplace) * 4 + 30;
  711.       if pipplace = frommove then
  712.         temp := 1
  713.       else
  714.         temp := 0;
  715.       ypos := 2 + abs(numberofpips) + temp;
  716.     end;
  717.   if ypos <> 11 then
  718.     begin
  719.       locate(ypos,xpos);
  720.       prompt('   ');
  721.     end;
  722.   if pipplace = tomove then
  723.     begin
  724.       locate(ypos,xpos);ansic(thisgame.sidetomove + 1);
  725.       if pipplayer = 1 then
  726.         prompt('«═»')
  727.       else
  728.         prompt('« »');
  729.     end;
  730. end;
  731.  
  732. procedure updatescreen;  {determine how to move pips}
  733. begin
  734.   processoffboardpips;
  735.   if (frommove > 0) and (frommove < 25) then
  736.     begin
  737.       pipplace := frommove;
  738.       movepips;
  739.       if tomove < 99 then
  740.         begin
  741.           pipplace := tomove;
  742.           movepips;
  743.         end;
  744.     end
  745.   else
  746.     begin
  747.       pipplace := tomove;
  748.       movepips;
  749.     end;
  750. end;
  751.  
  752. procedure savegame;     {saves game stats when Move is done}
  753. var
  754. ctr : integer;
  755. begin
  756.   if okansi then gotobottom;
  757.   ansic(1);
  758.   prompt('Your move(s) are saved...        ');
  759.   if player1 then
  760.     if offboard1 = 15 then
  761.       begin
  762.         thisgame.sidetomove := 3;
  763.         ansic(6);prompt('     You WON!!      ');
  764.         sysoplog('-» Won at Backgammon');
  765.       end
  766.     else
  767.       begin
  768.         thisgame.sidetomove := 2;
  769.       end;
  770.   if player2 then
  771.     if offboard2 = 15 then
  772.       begin
  773.         thisgame.sidetomove := 4;
  774.         ansic(6);prompt('     You WON!!'      );
  775.         sysoplog('-» Won at Backgammon');
  776.       end
  777.     else
  778.       begin
  779.         thisgame.sidetomove := 1;
  780.       end;
  781.   if not(okansi) then nl;
  782.   pausescr;
  783.   if tempdie1 > tempdie2 then
  784.     thisgame.lastroll := cstr(tempdie1)+cstr(tempdie2)
  785.   else
  786.     thisgame.lastroll := cstr(tempdie2)+cstr(tempdie1);
  787.   for ctr := 1 to 4 do
  788.     thisgame.lastmove[ctr] := ' ';
  789.   for ctr := 1 to movenumber do     {create last moves}
  790.     begin
  791.       thisgame.lastmove[ctr] := fromslot[ctr]+'-'+toslot[ctr];
  792.       if bumpcode[ctr] = 1 then
  793.         thisgame.lastmove[ctr] := thisgame.lastmove[ctr]+'(BUMP)';
  794.     end;
  795.   if not(nomove and (movenumber = 1)) then
  796.     thisgame.totalmoves := thisgame.totalmoves + movenumber;
  797.   thisgame.lastmovedate := date;
  798.   seek(gamefile,gameposition);
  799.   write(gamefile,thisgame);
  800. end;
  801.  
  802. procedure get2move;  {gets player 2's From and To moves - checks for illegal moves}
  803. var
  804. validinput,okfrom : boolean;
  805. fromcommand,tocommand : char;
  806. begin
  807.   validinput := false;
  808.   repeat
  809.     if okansi then
  810.       begin
  811.         locate(24,40);prompt('                                       ');
  812.         locate(24,40);ansic(3);
  813.       end;
  814.     prompt('From: ');okfrom := false;
  815.     if thisgame.piparray[0] > 0 then
  816.       begin
  817.         frommove := 0;okfrom := true;
  818.         prompt('BAR');
  819.         if not(okansi) then nl;
  820.         fromcommand := 'b';
  821.       end
  822.     else
  823.       begin
  824.         onek(fromcommand,'ABCDEFGHIJKLMNOPQRSTUVWX');
  825.         frommove := ord(fromcommand) - 64;
  826.         if thisgame.piparray[frommove] > -1 then
  827.           badmove
  828.         else
  829.           okfrom := true;
  830.       end;
  831.     if okfrom then
  832.       begin
  833.         if fromcommand = 'b' then
  834.           fromslot[movenumber] := 'BAR'
  835.         else
  836.           fromslot[movenumber] := fromcommand;
  837.         if okansi then
  838.           begin
  839.             locate(24,60);ansic(3);
  840.           end;
  841.         prompt('To: ');
  842.         onek(tocommand,'ABCDEFGHIJKLMNOPQRSTUVWXZ');
  843.         takingitoff := false;
  844.         if tocommand = 'Z' then
  845.           tomove := 99
  846.         else
  847.           tomove := ord(tocommand) - 64;
  848.         if tomove = 99 then
  849.           begin
  850.             if pipcode < 19 then
  851.               badmove
  852.             else
  853.               begin
  854.                 if (frommove = 25 - die2) or ((pipcode > 25 - die2) and (frommove = pipcode)) then
  855.                   begin
  856.                     validinput := true;
  857.                     takingitoff := true;
  858.                     die2 := die1;
  859.                   end
  860.                 else
  861.                   if (frommove = 25 - die1) or ((pipcode > 25 - die1) and (frommove = pipcode)) then
  862.                     begin
  863.                       validinput := true;
  864.                       takingitoff := true;
  865.                       die1 := die2;
  866.                     end;
  867.                 if not(validinput) then
  868.                   badmove;
  869.               end;
  870.           end
  871.         else
  872.           begin
  873.             if thisgame.piparray[tomove] > 1 then
  874.               badmove
  875.             else
  876.               begin
  877.                 if tomove - frommove = die1 then
  878.                   begin
  879.                     validinput := true;die1 := die2;
  880.                   end
  881.                 else
  882.                   if tomove - frommove = die2 then
  883.                     begin
  884.                       validinput := true;die2 := die1;
  885.                     end;
  886.                 if not(validinput) then
  887.                   badmove;
  888.             end;
  889.           end;
  890.       end;
  891.   until validinput or hangup;
  892.   if tocommand = 'Z' then
  893.     toslot[movenumber] := 'OFF'
  894.   else
  895.     toslot[movenumber] := tocommand;
  896. end;
  897.  
  898.  
  899. procedure player2move;  {do player 2's turn}
  900. var
  901. ctr : integer;
  902. begin
  903.   repeat
  904.     if okansi then
  905.       begin
  906.         gotobottom;prompt('                                ');gotobottom;
  907.       end
  908.     else asciidisplayscreen;
  909.     ansic(3);prompt('Your roll is: '+cstr(die1));
  910.     if movesleft > 1 then
  911.       prompt(' '+cstr(die2));
  912.     if not(okansi) then nl;
  913.     pipcode := 0;
  914.     if (thisgame.piparray[0] > 0) and (thisgame.piparray[die1] > 1) and (thisgame.piparray[die2] > 1) then
  915.       begin
  916.         nomove := true;movesleft := 0;moveok := true;
  917.       end
  918.     else
  919.       begin
  920.         while (thisgame.piparray[0] < 1) and (thisgame.piparray[pipcode] > -1) do
  921.           pipcode := pipcode + 1;
  922.         moveflag := 0;
  923.         if (thisgame.piparray[0] > 0) and (thisgame.piparray[die1] < 2) then
  924.           moveflag := 1;
  925.         if (thisgame.piparray[0] > 0) and (thisgame.piparray[die2] < 2) then
  926.           moveflag := 1;
  927.         for ctr := 1 to (24 - die1) do
  928.           if (thisgame.piparray[ctr] < 0) and (thisgame.piparray[ctr+die1] < 2) then
  929.             moveflag := 1;
  930.         for ctr := 1 to (24 - die2) do
  931.           if (thisgame.piparray[ctr] < 0) and (thisgame.piparray[ctr+die2] < 2) then
  932.             moveflag := 1;
  933.         if moveflag = 0 then
  934.           begin
  935.             if ((pipcode <19) or ((thisgame.piparray[25-die2] > -1) and (thisgame.piparray[25-die1] > -1) and
  936.             (pipcode < (25 - die1)))) then
  937.               begin
  938.                 nomove := true;movesleft := 0;moveok := true;
  939.               end;
  940.           end;
  941.         if not(nomove) then
  942.           begin
  943.             get2move;
  944.             if frommove = 0 then
  945.               thisgame.piparray[0] := thisgame.piparray[0] - 2;
  946.             thisgame.piparray[frommove] := thisgame.piparray[frommove] + 1;
  947.             if not(takingitoff) then
  948.               begin
  949.                 if thisgame.piparray[tomove] = 1 then
  950.                   begin
  951.                     thisgame.piparray[25] := thisgame.piparray[25] + 1;
  952.                     thisgame.piparray[tomove] := 0;
  953.                     bumpcode[movenumber] := 1;
  954.                   end;
  955.               end;
  956.             thisgame.piparray[tomove] := thisgame.piparray[tomove] - 1;
  957.             if okansi then updatescreen;
  958.             movenumber := movenumber + 1;
  959.             movesleft := movesleft - 1;
  960.             if offboard2 = 15 then
  961.               movesleft := 0;
  962.             if movesleft = 0 then
  963.               begin
  964.                 movenumber := movenumber - 1;
  965.                 if okansi then
  966.                   begin
  967.                     gotobottom;prompt('                                                                ');
  968.                     gotobottom;ansic(3);
  969.                   end
  970.                 else asciidisplayscreen;
  971.                 prompt('Is this ok? ');
  972.                 if yn then
  973.                   moveok := true
  974.                 else
  975.                   begin
  976.                     if okansi then
  977.                       begin
  978.                         gotobottom;ansic(1);
  979.                       end;
  980.                     prompt('Ok, try again then...              ');
  981.                     if not(okansi) then nl;
  982.                     pausescr;readgame;
  983.                     if okansi then displayscreen;
  984.                     initializemove;
  985.                   end;
  986.               end;
  987.           end;
  988.       end;
  989.   until ((movesleft = 0) and (moveok)) or hangup;
  990. end;
  991.  
  992. procedure get1move;  {get player 1's From and To moves}
  993. var
  994. validinput,okfrom : boolean;
  995. fromcommand,tocommand : char;
  996. begin
  997.   validinput := false;
  998.   repeat
  999.     if okansi then
  1000.       begin
  1001.         locate(24,40);prompt('                                       ');
  1002.         locate(24,40);ansic(2);
  1003.       end;
  1004.     prompt('From: ');okfrom := false;
  1005.     if thisgame.piparray[25] > 0 then
  1006.       begin
  1007.         frommove := 25;okfrom := true;
  1008.         prompt('BAR');
  1009.         if not(okansi) then nl;
  1010.         fromcommand := 'b';
  1011.       end
  1012.     else
  1013.       begin
  1014.         onek(fromcommand,'ABCDEFGHIJKLMNOPQRSTUVWX');
  1015.         frommove := ord(fromcommand) - 64;
  1016.         if thisgame.piparray[frommove] < 1 then
  1017.           badmove
  1018.         else
  1019.           okfrom := true;
  1020.       end;
  1021.     if okfrom then
  1022.       begin
  1023.         if fromcommand = 'b' then
  1024.           fromslot[movenumber] := 'BAR'
  1025.         else
  1026.           fromslot[movenumber] := fromcommand;
  1027.         if okansi then
  1028.           begin
  1029.             locate(24,60);ansic(2);
  1030.           end;
  1031.         prompt('To: ');
  1032.         onek(tocommand,'ABCDEFGHIJKLMNOPQRSTUVWXZ');
  1033.         takingitoff := false;
  1034.         if tocommand = 'Z' then
  1035.           tomove := 99
  1036.         else
  1037.           tomove := ord(tocommand) - 64;
  1038.         if tomove = 99 then
  1039.           begin
  1040.             if pipcode > 6 then
  1041.               badmove
  1042.             else
  1043.               begin
  1044.                 if (frommove = die2) or ((die2 > pipcode) and (frommove = pipcode)) then
  1045.                   begin
  1046.                     validinput := true;
  1047.                     takingitoff := true;
  1048.                     die2 := die1;
  1049.                   end
  1050.                 else
  1051.                   if (frommove = die1) or ((die1 > pipcode) and (frommove = pipcode)) then
  1052.                     begin
  1053.                       validinput := true;
  1054.                       takingitoff := true;
  1055.                       die1 := die2;
  1056.                     end;
  1057.                 if not(validinput) then
  1058.                   badmove;
  1059.               end;
  1060.           end
  1061.         else
  1062.           begin
  1063.             if thisgame.piparray[tomove] < -1 then
  1064.               badmove
  1065.             else
  1066.               begin
  1067.                 if frommove - tomove = die1 then
  1068.                   begin
  1069.                     validinput := true;die1 := die2;
  1070.                   end
  1071.                 else
  1072.                   if frommove - tomove = die2 then
  1073.                     begin
  1074.                       validinput := true;die2 := die1;
  1075.                     end;
  1076.                 if not(validinput) then
  1077.                   badmove;
  1078.             end;
  1079.           end;
  1080.       end;
  1081.   until validinput or hangup;
  1082.   if tocommand = 'Z' then
  1083.     toslot[movenumber] := 'OFF'
  1084.   else
  1085.     toslot[movenumber] := tocommand;
  1086. end;
  1087.  
  1088. procedure player1move;   {do player 1's turn}
  1089. var
  1090. ctr : integer;
  1091. begin
  1092.   repeat
  1093.     if okansi then
  1094.       begin
  1095.         gotobottom;prompt('                                ');gotobottom;
  1096.       end
  1097.     else asciidisplayscreen;
  1098.     ansic(2);prompt('Your roll is: '+cstr(die1));
  1099.     if movesleft > 1 then
  1100.       prompt(' '+cstr(die2));
  1101.     if not(okansi) then nl;
  1102.     pipcode := 25;
  1103.     if (thisgame.piparray[25] > 0) and (thisgame.piparray[25-die1] < -1) and (thisgame.piparray[25-die2] < -1) then
  1104.       begin
  1105.         nomove := true;movesleft := 0;moveok := true;
  1106.       end
  1107.     else
  1108.       begin
  1109.         while thisgame.piparray[pipcode] < 1 do
  1110.           pipcode := pipcode - 1;
  1111.         moveflag := 0;
  1112.         for ctr := (die1 + 1) to 25 do
  1113.           if (thisgame.piparray[ctr] > 0) and (thisgame.piparray[ctr-die1] > -2) then
  1114.             moveflag := 1;
  1115.         for ctr := (die2 + 1) to 25 do
  1116.           if (thisgame.piparray[ctr] > 0) and (thisgame.piparray[ctr-die2] > -2) then
  1117.             moveflag := 1;
  1118.         if moveflag = 0 then
  1119.           begin
  1120.             if ((pipcode > 6) or ((thisgame.piparray[die2] < 1) and (thisgame.piparray[die1] < 1) and (pipcode > die1))) then
  1121.               begin
  1122.                 nomove := true;movesleft := 0;moveok := true;
  1123.               end;
  1124.           end;
  1125.         if not(nomove) then
  1126.           begin
  1127.             get1move;
  1128.             thisgame.piparray[frommove] := thisgame.piparray[frommove] - 1;
  1129.             if not(takingitoff) then
  1130.               begin
  1131.                 if thisgame.piparray[tomove] = -1 then
  1132.                   begin
  1133.                     thisgame.piparray[0] := thisgame.piparray[0] + 1;
  1134.                     thisgame.piparray[tomove] := 0;
  1135.                     bumpcode[movenumber] := 1;
  1136.                   end;
  1137.               end;
  1138.             thisgame.piparray[tomove] := thisgame.piparray[tomove] + 1;
  1139.             if okansi then updatescreen;
  1140.             movenumber := movenumber + 1;
  1141.             movesleft := movesleft - 1;
  1142.             if offboard1 = 15 then
  1143.               movesleft := 0;
  1144.             if movesleft = 0 then
  1145.               begin
  1146.                 movenumber := movenumber - 1;
  1147.                 if okansi then
  1148.                   begin
  1149.                     gotobottom;prompt('                                                                     ');
  1150.                     gotobottom;ansic(2);
  1151.                   end
  1152.                 else asciidisplayscreen;
  1153.                 prompt('Is this ok? ');
  1154.                 if yn then
  1155.                   moveok := true
  1156.                 else
  1157.                   begin
  1158.                     if okansi then
  1159.                       begin
  1160.                         gotobottom;ansic(1);
  1161.                       end;
  1162.                     prompt('Ok, try again then...             ');
  1163.                     if not(okansi) then nl;
  1164.                     pausescr;readgame;
  1165.                     if okansi then displayscreen;
  1166.                     initializemove;
  1167.                   end;
  1168.               end;
  1169.           end;
  1170.       end;
  1171.   until ((movesleft = 0) and (moveok)) or hangup;
  1172. end;
  1173.  
  1174. procedure ansigame;
  1175. begin
  1176.   repeat
  1177.     cls;
  1178.     if cs then     {draw sysop functions on menu}
  1179.       begin
  1180.         locate(2,32);ansic(5);prompt('B - ');
  1181.         ansic(1);prompt('Build a game (sysop only)');
  1182.       end;
  1183.     locate(4,28);ansic(5);prompt('----» Game set number: ');
  1184.     ansic(1);prompt(cstr(setnumber));ansic(5);prompt(' «----');
  1185.     locate(8,32);ansic(5);prompt('C - ');
  1186.     ansic(1);prompt('Change set number');
  1187.     locate(10,32);ansic(5);prompt('E - ');
  1188.     ansic(1);prompt('Enter a game');
  1189.     locate(12,32);ansic(5);prompt('I - ');
  1190.     ansic(1);prompt('Instructions');
  1191.     locate(14,32);ansic(5);prompt('M - ');
  1192.     ansic(1);prompt('Make move(s)');
  1193.     locate(16,32);ansic(5);prompt('V - ');
  1194.     ansic(1);prompt('View a game');
  1195.     locate(18,32);ansic(5);prompt('Q - ');
  1196.     ansic(1);prompt('Quit to BBS');
  1197.     gotobottom;
  1198.     prt('Which? ');
  1199.     onek(command,'BCEIMVQ');
  1200.     case command of
  1201.       'B':begin
  1202.             if cs then
  1203.               begin
  1204.                 getgame;
  1205.                 if oktocontinue then
  1206.                   buildgame;
  1207.               end;
  1208.           end;
  1209.       'C':changeset;
  1210.       'E':begin
  1211.             getgame;
  1212.             if oktocontinue then begin
  1213.               if thisgame.sidetomove>2 then begin {game open}
  1214.                 if (thisuser.name<>thisgame.player1name) and (thisgame.sidetomove=5)
  1215.                 then begin  {sign up player 2 & start}
  1216.                   thisgame.player2name:=thisuser.name;
  1217.                   resetgame;
  1218.                   seek(gamefile,gameposition);
  1219.                   write(gamefile,thisgame);
  1220.                   nl;
  1221.                   print('Done -- game initialized.');
  1222.                   pausescr;
  1223.                 end else begin
  1224.                   thisgame.player1name:=thisuser.name;
  1225.                   thisgame.player2name:='-OPEN-';
  1226.                   thisgame.sidetomove:=5;
  1227.                   seek(gamefile,gameposition);
  1228.                   write(gamefile,thisgame);
  1229.                   print('Done -- your name has been added to the game.');
  1230.                   pausescr;
  1231.                 end;
  1232.               end else begin
  1233.                 print('Select an OPEN game!');
  1234.                 pausescr;
  1235.               end;
  1236.             end;
  1237.           end;
  1238.       'I':begin
  1239.             cls;pauseon;
  1240.             printfile('gammon.txt');
  1241.             pauseoff;pausescr;
  1242.           end;
  1243.       'M':begin
  1244.             getgame;
  1245.             if oktocontinue then
  1246.               begin
  1247.                 checkformoveaccess;
  1248.                 if oktomove then
  1249.                   begin
  1250.                     rolldice;
  1251.                     displayscreen;
  1252.                     initializemove;
  1253.                     if player1 then
  1254.                       player1move
  1255.                     else
  1256.                       player2move;
  1257.                     if nomove then
  1258.                       begin              {player couldn't move}
  1259.                         prompt('                                                                 ');
  1260.                         prompt(#7);ansic(6);locate(24,40);
  1261.                         prompt('You can''t move!!      ');
  1262.                         pausescr;
  1263.                         fromslot[movenumber] := 'NO';
  1264.                         toslot[movenumber] := 'MOVE';
  1265.                       end;
  1266.                     if not(hangup) then  {if user hung up don't save - could}
  1267.                       savegame;          {mess up the data}
  1268.                   end;
  1269.               end;
  1270.           end;
  1271.       'V':begin
  1272.             getgame;
  1273.             if oktocontinue then
  1274.               begin
  1275.                 displayscreen;
  1276.                 pausescr;
  1277.               end;
  1278.           end;
  1279.     end;
  1280.   until (command = 'Q') or hangup;
  1281. end;
  1282.  
  1283. procedure asciigame;
  1284. begin
  1285.   repeat
  1286.     cls;nl;nl;
  1287.     if cs then
  1288.       begin
  1289.         print('B - Build a game (sysop only)');
  1290.       end;
  1291.     print('Game set number: '+cstr(setnumber));
  1292.     nl;print('C - Change set number');
  1293.     print('E - Enter a game');
  1294.     print('I - Instructions');
  1295.     print('M - Make move(s)');
  1296.     print('V - View a game');
  1297.     print('Q - Quit to BBS');
  1298.     nl;prompt('Which? ');
  1299.     onek(command,'BCEIMVQ');
  1300.     case command of
  1301.       'B':begin
  1302.             if cs then
  1303.               begin
  1304.                 getgame;
  1305.                 if oktocontinue then
  1306.                   buildgame;
  1307.               end;
  1308.           end;
  1309.       'C':changeset;
  1310.       'E':begin
  1311.             getgame;
  1312.             if oktocontinue then begin
  1313.               if thisgame.sidetomove>2 then begin {game open}
  1314.                 if (thisuser.name<>thisgame.player1name) and (thisgame.sidetomove=5)
  1315.                 then begin  {sign up player 2 & start}
  1316.                   thisgame.player2name:=thisuser.name;
  1317.                   resetgame;
  1318.                   seek(gamefile,gameposition);
  1319.                   write(gamefile,thisgame);
  1320.                   nl;
  1321.                   print('Done -- game initialized.');
  1322.                   pausescr;
  1323.                 end else begin
  1324.                   thisgame.player1name:=thisuser.name;
  1325.                   thisgame.player2name:='-OPEN-';
  1326.                   thisgame.sidetomove:=5;
  1327.                   seek(gamefile,gameposition);
  1328.                   write(gamefile,thisgame);
  1329.                   print('Done -- your name has been added to the game.');
  1330.                   pausescr;
  1331.                 end;
  1332.               end else begin
  1333.                 print('Select an OPEN game!');
  1334.                 pausescr;
  1335.               end;
  1336.             end;
  1337.           end;
  1338.       'I':begin
  1339.             cls;pauseon;
  1340.             printfile('gammon2.txt');
  1341.             pauseoff;
  1342.             pausescr;
  1343.           end;
  1344.       'M':begin
  1345.             getgame;
  1346.             if oktocontinue then
  1347.               begin
  1348.                 checkformoveaccess;
  1349.                 if oktomove then
  1350.                   begin
  1351.                     rolldice;
  1352.                     initializemove;
  1353.                     if player1 then player1move
  1354.                     else player2move;
  1355.                     if nomove then
  1356.                       begin
  1357.                         nl;prompt(#7);print('You can''t move!!');
  1358.                         pausescr;
  1359.                         fromslot[movenumber] := 'NO';
  1360.                         toslot[movenumber] := 'MOVE';
  1361.                       end;
  1362.                     if not(hangup) then savegame;
  1363.                   end;
  1364.               end;
  1365.           end;
  1366.       'V':begin
  1367.             getgame;
  1368.             if oktocontinue then
  1369.               begin
  1370.                 asciidisplayscreen;
  1371.                 pausescr;
  1372.               end;
  1373.           end;
  1374.     end;
  1375.   until (command = 'Q') or hangup;
  1376. end;
  1377.  
  1378. begin
  1379.   iport;
  1380.   initialize;
  1381.   if okansi then introduction else asciiintroduction;
  1382.   if okansi then ansigame else asciigame;
  1383.   Greturn;
  1384. end.
  1385.  
  1386.