home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / top2src.zip / BJ4TOP.ZIP / BJOLD.PAS < prev    next >
Pascal/Delphi Source File  |  1996-01-01  |  59KB  |  1,697 lines

  1. {$A+,B-,D-,E+,F-,G-,I+,L-,N-,O-,R-,S+,V+,X-}
  2. {$M 16384,0,0}
  3. {$V-}
  4. Program Blackjack4RAP;
  5. Uses DOS, Crt, BJSupp, NewReg;
  6.  
  7. Type
  8.   IDXRec = Record
  9.              Alias : String[30];
  10.              RealName : String[40];
  11.              Baud : Word;
  12.              Location : String[25];
  13.              Gender : Word;
  14.              Description : String[60];
  15.              Age : Byte;
  16.              Quiet : ShortInt;
  17.              Task : ShortInt;
  18.              Buf : Array [1..346] of byte;
  19.            end;
  20.  
  21.   Str30 = String[30];
  22.   Str255 = String[255];
  23.  
  24.   NodeRec = Record
  25.              Kind : Word;
  26.              From : Word;
  27.              DoneTo : Integer;
  28.              Gender : Word;
  29.              Alias : Str30;
  30.              Data : Str255;
  31.              {$IFDEF OLDRAP}
  32.              {$ELSE}
  33.              TTTStart : Integer;
  34.              {$ENDIF}
  35.            end;
  36.  
  37.   ConfigRec = Record
  38.                 StartCD : Word;
  39.                 BetCD : Byte;
  40.                 MaxBet : Byte;
  41.                 MinBet : Byte;
  42.                 TimeBetweenGames : Byte;
  43.                 FirstWarn : Byte;
  44.                 SecondWarn : Byte;
  45.                 BootFromBJ : Byte;
  46.               end;
  47.  
  48. Type
  49.   RegisterRec = record
  50.                   TheReg : string;
  51.                   TheName : string;
  52.                 end;
  53. Const
  54.   RegisterData : RegisterRec
  55.                = ( TheReg : '00000000000';
  56.                    TheName : '[UNREGISTERED]');
  57.  
  58.   ProgVerStr = ' v0.90wb';
  59.  
  60.   fmReadOnly  = $00;
  61.   fmWriteOnly = $01;
  62.   fmReadWrite = $02;
  63.  
  64.   fmDenyAll   = $10;
  65.   fmDenyWrite = $20;
  66.   fmDenyRead  = $30;
  67.   fmDenyNone  = $40;
  68.  
  69.   ConfigData : ConfigRec
  70.                = ( StartCD : 1000;
  71.                    BetCD : 10;
  72.                    MaxBet : 100;
  73.                    MinBet : 10;
  74.                    TimeBetweenGames : 19;
  75.                    FirstWarn : 60;
  76.                    SecondWarn : 90;
  77.                    BootFromBJ : 125
  78.                   );
  79.  
  80.   HelpData : Array[1..15] of String = (
  81.   #13#10'^^0EEnter ^^0D/BJ BET ^^0C<amount> ^^0Eto change your bet (cannot be done during a game).',
  82.   '^^0EEnter ^^0D/BJ CD ^^0Eor ^^0D/BJ $ ^^0Efor your current number of Cyberdollars.',
  83.   '^^0EEnter ^^0D/BJ DOUBLE ^^0Eto double down.',
  84.   '^^0EEnter ^^0D/BJ DOUBLE 2 ^^0Eto double down on your second hand.',
  85.   '^^0EEnter ^^0D/BJ HAND ^^0Eto view the dealer''s and your own cards.',
  86.   '^^0EEnter ^^0D/BJ HELP ^^0Efor this commands list.',
  87.   '^^0EEnter ^^0D/BJ HIT ^^0Eto be dealt a card.',
  88.   '^^0EEnter ^^0D/BJ HIT 2 ^^0Eto be dealt a card to your second hand.',
  89.   '^^0EEnter ^^0D/BJ INSURE ^^0Eto make an insurance bet against a blackjack.',
  90.   '^^0EEnter ^^0D/BJ OFF ^^0Eto be dealt out of blackjack.',
  91.   '^^0EEnter ^^0D/BJ ON ^^0Eto join in the next game of blackjack.',
  92.   '^^0EEnter ^^0D/BJ SCAN ^^0Eto see who''s playing blackjack.',
  93.   '^^0EEnter ^^0D/BJ SPLIT ^^0Eto split your hand.',
  94.   '^^0EEnter ^^0D/BJ STAY ^^0Eto end your turn.',
  95.   '^^0EEnter ^^0D/BJ TURN ^^0Eto see who''s turn it is.'#13#10);
  96.  
  97.   ComList : Array[1..16] of String = ('BJ BET', 'BJ $',
  98.   'BJ CD', 'BJ DOUBLE', 'BJ DOUBLE2', 'BJ HAND', 'BJ HELP', 'BJ HIT',
  99.   'BJ HIT 2', 'BJ INSURE', 'BJ OFF', 'BJ ON', 'BJ SCAN', 'BJ SPLIT',
  100.   'BJ STAY', 'BJ TURN');
  101.  
  102.  
  103. Var
  104.   IPCDir : String;
  105.   Node : Byte;
  106.   NodeStr : String;
  107.   NodeData : NodeRec;
  108.   NodeData2 : NodeRec;
  109.   GamePlaying : Boolean;
  110.   L : Word;
  111.   Sec : Word;
  112.   OldSec : Word;
  113.   SecPassed : Word;
  114.   NodeTurn : Integer;
  115.   NodeStat : Array [1..255] of Byte; { 0 = Not in game }
  116.                                      { 1 = Waiting }
  117.                                      { 2 = In game }
  118.   NodeCD : Array [1..255] of LongInt;
  119.   NodeInsure : Array [1..255] of Boolean;
  120.   NodeHand : Array [1..255] of String[24];
  121.   NodeHand2 : Array [1..255] of String[24];
  122.   NodeDoneH1  : Array [1..255] of Boolean;
  123.   NodeDoneH2 : Array [1..255] of Boolean;
  124.   NodeBet : Array [1..255] of byte;
  125.   NodeDD : Array [1..255] of byte;
  126.   NodeDD2 : Array [1..255] of byte;
  127.   UsedCards : String;
  128.   DealerHand : String[40];
  129.  
  130. Procedure InitScr;
  131. Var
  132.   Loop : Word;
  133. begin
  134.   TextAttr := $71;
  135.   ClrScr;
  136.   GotoXY (1,2);
  137.   For loop := 1 to 1920 do Write ('░');
  138.   Textbackground (blue);
  139.   GotoXY (1,1);
  140.   Textbackground (7);
  141.   Textcolor (red);
  142.   Write (' Blackjack for RAP'+ProgVerStr);
  143.   Textcolor (0);
  144.   Write (' Configuration (c) 1994 by David Ong, OmniWare(tm)');
  145.   ClrEol;
  146.   GotoXY (1,25);
  147.   Textcolor (Red);
  148.   Write (' Help: ');
  149.   Textcolor (0);
  150.   Write ('Use cursor keys to select a choice.');
  151.   ClrEol;
  152.   WindowBorder (4,3,60,13,White,7);
  153.   TextAttr := $7F;
  154.   GotoXY (27,3);
  155.   Write ('┤ Config ├');
  156.   GotoXY (6,4);
  157.   Textcolor (0);
  158.   Writeln ('Starting Cyberdollars:');
  159.   GotoXY (6,5);
  160.   Writeln ('Minimum bet:');
  161.   GotoXY (6,6);
  162.   Writeln ('Maximum bet: ');
  163.   GotoXY (6,7);
  164.   Writeln ('Time between games:');
  165.   GotoXY (6,8);
  166. {  For Loop := 1 to 9 do WriteField (Loop);}
  167. end;
  168.  
  169. Procedure ConfigureBJ;
  170. begin
  171.   InitScr;
  172.   Halt;
  173. end;
  174.  
  175. Procedure SaveReg;
  176. Var
  177.   ExeFile    : file;
  178.   HeaderSize : word;
  179.   FileName : String;
  180.  
  181. begin
  182.   FileName := ParamStr (0);
  183.   Writeln ('Writing registration codes to ', FileName);
  184.   Assign (ExeFile, FileName);
  185.   Reset (ExeFile, 1);
  186.   Seek      (ExeFile, 8);
  187.   Blockread (ExeFile, HeaderSize, Sizeof (HeaderSize));
  188.   Seek      (ExeFile, Longint(16) * (seg(RegisterData)
  189.             - PrefixSeg + HeaderSize) + ofs (RegisterData) - 256);
  190.   Blockwrite (ExeFile, RegisterData, sizeof (RegisterData));
  191.   Close      (ExeFile);
  192. end;
  193.  
  194. Procedure Enter_Reg;
  195. begin
  196.   Writeln;
  197.   Writeln ('BJ4RAP Registration--Your registration code and named will be saved to');
  198.   Writeln ('  the ', ParamStr(0), ' file.');
  199.   Writeln;
  200.   Write ('Your Name (Please note it is case sensitive): ');
  201.   Readln (RegisterData.TheName);
  202.   Write ('Registration Number:');
  203.   Readln (RegisterData.TheReg);
  204.   Writeln;
  205.   UserName := RegisterData.TheName;
  206.   RegisterNum := RegisterData.TheReg;
  207.   Check_Register;
  208.   If Registered then Writeln ('The registration number checks out, thank you for registering')
  209.   else
  210.   begin
  211.     Writeln ('The registration number doesn''t check out, make sure you''ve entered');
  212.     Writeln ('everything correctly!'+#7);
  213.     Writeln;
  214.     Writeln ('Name and registration number not saved.');
  215.     Halt (1);
  216.   end;
  217.   Writeln;
  218.   If Not FExists (ParamStr (0)) then Writeln ('Error: The file '+ParamStr(0)+' could not be written to.'+#7)
  219.   else SaveReg;
  220. end;
  221.  
  222. Procedure InitProgram;
  223. begin
  224.   Randomize;
  225.   Writeln;
  226.   Writeln ('Blackjack for RAP'+ProgVerStr);
  227.   Writeln ('Copyright (c) 1995 by David Ong, OmniWare(tm), All Rights Reserved.');
  228.   Writeln;
  229.   If ParamCount < 1 then
  230.   begin
  231.     Writeln ('Command line parameter(s) missing!');
  232.     Writeln;
  233.     Writeln ('Usage: BJ4RAP <work path> [<node>]');
  234.     Writeln;
  235.     Writeln ('<work path>  Is the path to RAP''s work directory.');
  236.     Writeln ('<node>       Is optional and if given will force BJ4RAP to use the node even');
  237.     Writeln ('             if it is already taken.');
  238.     Writeln;
  239.     Writeln ('Eg: BJ4RAP d:\rap\workdir');
  240.     Writeln ('For further help refer to BJ4RAP.DOC');
  241.     Halt;
  242.   end;
  243.   RegisterKey := '#####';
  244.   UserName := RegisterData.TheName;
  245.   RegisterNum := RegisterData.TheReg;
  246.   Check_Register;
  247.   If UpStr(ParamStr (1)) = '/REGISTER' then
  248.   begin
  249.     Enter_Reg;
  250.     Halt;
  251.   end;
  252. { If UpStr(ParamStr(1)) = '/CONFIG' then ConfigureBJ;}
  253.   IPCDir := ParamStr(1);
  254.   If IPCDir[Length(IPCDir)] <> '\' then IPCDir := IPCDir + '\';
  255.   FileMode:=fmReadWrite+FmDenyNone;
  256.   If not FExists (IPCDir + 'NODEIDX.RAP') then
  257.   begin
  258.     Writeln ('Error: The NODEIDX.RAP file was not found in the ', UpStr(IPCDir), ' directory!');
  259.     Writeln ('Make sure RAP uses the same work path and has been previously run or is'#13#10'currently running.');
  260.     Halt;
  261.   end;
  262.   If not FExists (IPCDir + 'NODEIDX2.RAP') then
  263.   begin
  264.     Writeln ('Error: The NODEIDX2.RAP file was not found in the ', UpStr(IPCDir), ' directory!');
  265.     Writeln ('Make sure RAP uses the same work path and has been previously run or is'#13#10'currently running.');
  266.     Halt;
  267.   end;
  268. end;
  269.  
  270. Function UnUsedNode : byte;
  271. Var
  272.   f : file of byte;
  273.   L : byte;
  274.   B : byte;
  275.   Error : Integer;
  276. begin
  277.   If Paramcount < 2 then
  278.   begin
  279.     L := 0;
  280.     Assign (F, IPCDir + 'NODEIDX2.RAP');
  281.     Reset (f);
  282.     Repeat
  283.       Inc (l);
  284.       {$I-}
  285.       Repeat
  286.         Read (f,b);
  287.       Until IOResult = 0;
  288.       {$I+}
  289.     Until b = 0;
  290.     Close (f);
  291.   end
  292.   else
  293.   begin
  294.     Val (ParamStr(2), L, Error);
  295.     If (Error <> 0) or (L = 0) then
  296.     begin
  297.       Writeln ('Invalid forced node passed!');
  298.       Writeln ('Node must be from 1 to 255');
  299.       Halt;
  300.     end;
  301.   end;
  302.   UnUsedNode := L;
  303. end;
  304.  
  305. Procedure TakeNode;
  306. Var
  307.   L : byte;
  308.   B : byte;
  309.   f : File of byte;
  310.   IDXFile : File of IDXRec;
  311.   IDXData : IDXRec;
  312. begin
  313.   L := 0;
  314.   Assign (f, IPCDir + 'NODE'+NodeStr+'.RAP');
  315.   Rewrite (f);
  316.   Close (f);
  317.   Assign (f, IPCDir + 'MIDX'+NodeStr+'.RAP');
  318.   Rewrite (f);
  319.   Close (f);
  320.   Assign (F, IPCDir + 'NODEIDX2.RAP');
  321.   Reset (f);
  322.   Seek (f, Node - 1);
  323.   b := 1;
  324.   {$I-}
  325.   Repeat
  326.     Write (f,b);
  327.   Until IOResult = 0;
  328.   {$I+}
  329.   Close (f);
  330.   Assign (IDXFile, IPCDir + 'NODEIDX.RAP');
  331.   Reset (IDXFile);
  332.   Seek (IDXFile, Node - 1);
  333.   FillChar (IDXData, SizeOf(IDXData), #0);
  334.   IDXData.Alias := '^0FBJ'#8'lackjack Dealer'#0;
  335.   IDXData.Alias[0] := '^';
  336.   IDXData.RealName := 'J'#0;
  337.   IDXData.RealName[0] := 'B';
  338.   IDXData.Baud := 0;
  339.   If registered then
  340.   begin
  341.     IDXData.Location := 'egistered'+#0;
  342.     IDXData.Location[0] := 'R';
  343.   end
  344.   else
  345.   begin
  346.     IDXData.Location := 'NREGISTERED'+#0;
  347.     IDXData.Location[0] := 'U';
  348.   end;
  349.   IDXData.Gender := 0;
  350.   {$I-}
  351.   Repeat
  352.     Write (IDXFile, IDXData);
  353.   Until IOResult = 0;
  354.   {$I+}
  355.   Close (IDXFile);
  356. end;
  357.  
  358. Procedure SendMSG (N : byte; NodeData : NodeRec);
  359. Var
  360.   b : byte;
  361.   f : File of byte;
  362.   NodeFile : File of NodeRec;
  363. begin
  364.   Assign (f, IPCDir + 'MIDX' + PaddedNum(N)+'.RAP');
  365.   Reset (f);
  366.   b := 0;
  367.   If not Eof (f) then
  368.   Repeat
  369.     {$I-}
  370.     Repeat
  371.       Read (f,b);
  372.     Until IOResult = 0;
  373.     {$I+}
  374.     If Eof (f) then
  375.     begin
  376.       b := 0;
  377.       Write (f,b);
  378.     end;
  379.   Until B = 0
  380.   else Write (f,b);
  381.   b := 1;
  382.   Seek (f, FilePos(f) - 1);
  383.   {$I-}
  384.   Repeat
  385.     Write (f,b);
  386.   Until IOResult = 0;
  387.   {$I+}
  388.   Assign (NodeFile, IPCDir + 'NODE' + PaddedNum(N)+'.RAP');
  389.   Reset (NodeFile);
  390.   Seek (NodeFile, FilePos(f) - 1);
  391.   {$I-}
  392.   Repeat
  393.     Write (NodeFile, NodeData);
  394.   Until IOResult = 0;
  395.   {$I+}
  396.   Close (NodeFile);
  397.   Close (f);
  398.   Assign (F, IPCDir + 'CHGIDX.RAP');
  399.   Reset (f);
  400.   Seek (f, N - 1);
  401.   b := 1;
  402.   {$I-}
  403.   Repeat
  404.     Write (f,b);
  405.   Until IOResult = 0;
  406.   {$I+}
  407.   Close (f);
  408. end;
  409.  
  410. Procedure BroadCast (T : Byte; Alias : Str30; Data : Str255);
  411. Var
  412.   IDX2 : File of byte;
  413.   b : byte;
  414.   L : Word;
  415.   NodeData : NodeRec;
  416. begin
  417.   FillChar (NodeData, SizeOf(NodeData), #0);
  418.   NodeData.Doneto := -1;
  419.   {$IFDEF OLDRAP}
  420.   {$ELSE}
  421.   NodeData.TTTStart := -1;
  422.   {$ENDIF}
  423.   Alias := Alias + #0;
  424.   Data := Data + #0;
  425.   NodeData.Kind := T;
  426.   NodeData.From := Node - 1;
  427.   NodeData.Alias := Minus1 (Alias);
  428.   NodeData.Alias[0] := Alias[1];
  429.   NodeData.Data := Minus1 (Data);
  430.   NodeData.Data[0] := Data[1];
  431.   Assign (IDX2, IPCDir + 'NODEIDX2.RAP');
  432.   {$I-}
  433.   Repeat
  434.     Reset (IDX2);
  435.   Until IOResult = 0;
  436.   {$I+}
  437.   For L := 1 to 255 do
  438.   begin
  439.     {$I-}
  440.     Repeat
  441.       Read (IDX2, b);
  442.     Until IOResult = 0;
  443.     {$I+}
  444.     If (L <> Node) and (b=1) and (NodeStat[L] <> 0) then SendMSG (L, NodeData);
  445.   end;
  446.   Close (IDX2);
  447. end;
  448.  
  449. Procedure BroadCastAll (T : Byte; Alias : Str30; Data : Str255);
  450. Var
  451.   IDX2 : File of byte;
  452.   b : byte;
  453.   L : Word;
  454.   NodeData : NodeRec;
  455. begin
  456.   FillChar (NodeData, SizeOf(NodeData), #0);
  457.   NodeData.Doneto := -1;
  458.   {$IFDEF OLDRAP}
  459.   {$ELSE}
  460.   NodeData.TTTStart := -1;
  461.   {$ENDIF}
  462.   Alias := Alias + #0;
  463.   Data := Data + #0;
  464.   NodeData.Kind := T;
  465.   NodeData.From := Node - 1;
  466.   NodeData.Alias := Minus1 (Alias);
  467.   NodeData.Alias[0] := Alias[1];
  468.   NodeData.Data := Minus1 (Data);
  469.   NodeData.Data[0] := Data[1];
  470.   Assign (IDX2, IPCDir + 'NODEIDX2.RAP');
  471.   {$I-}
  472.   Repeat
  473.     Reset (IDX2);
  474.   Until IOResult = 0;
  475.   {$I+}
  476.   For L := 1 to 255 do
  477.   begin
  478.     {$I-}
  479.     Repeat
  480.       Read (IDX2, b);
  481.     Until IOResult = 0;
  482.     {$I+}
  483.     If (L <> Node) and (b=1) then SendMSG (L, NodeData);
  484.   end;
  485.   Close (IDX2);
  486. end;
  487.  
  488. Procedure BroadCastAllBut (T : Byte; Alias : Str30; Data : Str255; NoSend : Byte);
  489. Var
  490.   IDX2 : File of byte;
  491.   b : byte;
  492.   L : Word;
  493.   NodeData : NodeRec;
  494. begin
  495.   FillChar (NodeData, SizeOf(NodeData), #0);
  496.   NodeData.Doneto := -1;
  497.   {$IFDEF OLDRAP}
  498.   {$ELSE}
  499.   NodeData.TTTStart := -1;
  500.   {$ENDIF}
  501.   Alias := Alias + #0;
  502.   Data := Data + #0;
  503.   NodeData.Kind := T;
  504.   NodeData.From := Node - 1;
  505.   NodeData.Alias := Minus1 (Alias);
  506.   NodeData.Alias[0] := Alias[1];
  507.   NodeData.Data := Minus1 (Data);
  508.   NodeData.Data[0] := Data[1];
  509.   Assign (IDX2, IPCDir + 'NODEIDX2.RAP');
  510.   {$I-}
  511.   Repeat
  512.     Reset (IDX2);
  513.   Until IOResult = 0;
  514.   {$I+}
  515.   For L := 1 to 255 do
  516.   begin
  517.     {$I-}
  518.     Repeat
  519.       Read (IDX2, b);
  520.     Until IOResult = 0;
  521.     {$I+}
  522.     If (L <> Node) and (b=1) and (NoSend <> L) then SendMSG (L, NodeData);
  523.   end;
  524.   Close (IDX2);
  525. end;
  526.  
  527. Procedure GiveMSG (T : Byte; Alias : Str30; Data : Str255; Node : Byte);
  528. Var
  529.   IDX2 : File of byte;
  530.   b : byte;
  531.   L : Word;
  532.   NodeData : NodeRec;
  533. begin
  534.   FillChar (NodeData, SizeOf(NodeData), #0);
  535.   NodeData.Doneto := -1;
  536.   {$IFDEF OLDRAP}
  537.   {$ELSE}
  538.   NodeData.TTTStart := -1;
  539.   {$ENDIF}
  540.   Alias := Alias + #0;
  541.   Data := Data + #0;
  542.   NodeData.Kind := T;
  543.   NodeData.From := Node - 1;
  544.   NodeData.Alias := Minus1 (Alias);
  545.   NodeData.Alias[0] := Alias[1];
  546.   NodeData.Data := Minus1 (Data);
  547.   NodeData.Data[0] := Data[1];
  548.   SendMSG (Node, NodeData);
  549. end;
  550.  
  551. Procedure BroadCastBut (T : Byte; Alias : Str30; Data : Str255; NoSend : Byte);
  552. Var
  553.   IDX2 : File of byte;
  554.   b : byte;
  555.   L : Word;
  556.   NodeData : NodeRec;
  557. begin
  558.   FillChar (NodeData, SizeOf(NodeData), #0);
  559.   NodeData.Doneto := -1;
  560.   {$IFDEF OLDRAP}
  561.   {$ELSE}
  562.   NodeData.TTTStart := -1;
  563.   {$ENDIF}
  564.   Alias := Alias + #0;
  565.   Data := Data + #0;
  566.   NodeData.Kind := T;
  567.   NodeData.From := Node - 1;
  568.   NodeData.Alias := Minus1 (Alias);
  569.   NodeData.Alias[0] := Alias[1];
  570.   NodeData.Data := Minus1 (Data);
  571.   NodeData.Data[0] := Data[1];
  572.   Assign (IDX2, IPCDir + 'NODEIDX2.RAP');
  573.   {$I-}
  574.   Repeat
  575.     Reset (IDX2);
  576.   Until IOResult = 0;
  577.   {$I+}
  578.   For L := 1 to 255 do
  579.   begin
  580.     {$I-}
  581.     Repeat
  582.       Read (IDX2, b);
  583.     Until IOResult = 0;
  584.     {$I+}
  585.     If (L <> Node) and (b=1) and (L <> NoSend) and (NodeStat[L] <> 0) then SendMSG (L, NodeData);
  586.   end;
  587.   Close (IDX2);
  588. end;
  589.  
  590. Function NodeUser (I : Integer) : String;
  591. Var
  592.   IDXFile : File of IDXRec;
  593.   IDXData : IDXRec;
  594. begin
  595.   If I > 0 then
  596.   begin
  597.     Assign (IDXFile, IPCDir + 'NODEIDX.RAP');
  598.     Reset (IDXFile);
  599.     Seek (IDXFile, I - 1);
  600.     {$I-}
  601.     Repeat
  602.       Read (IDXFile, IDXData);
  603.     Until IOResult = 0;
  604.     {$I+}
  605.     NodeUser := CStr (IDXData.Alias);
  606.     Close (IDXFile);
  607.   end
  608.   else NodeUser := 'everyone';
  609. end;
  610.  
  611. Function NodeGender (I : Word) : Boolean;
  612. Var
  613.   IDXFile : File of IDXRec;
  614.   IDXData : IDXRec;
  615. begin
  616.   If I > 0 then
  617.   begin
  618.     Assign (IDXFile, IPCDir + 'NODEIDX.RAP');
  619.     Reset (IDXFile);
  620.     Seek (IDXFile, I - 1);
  621.     {$I-}
  622.     Repeat
  623.       Read (IDXFile, IDXData);
  624.     Until IOResult = 0;
  625.     {$I+}
  626.     Close (IDXFile);
  627.     NodeGender := IDXData.Gender = 1;
  628.   end
  629.   else NodeGender := False;
  630. end;
  631.  
  632. Procedure InitRAP;
  633. begin
  634.   Node := UnusedNode;
  635.   Writeln ('Logging onto RAP as node ', Node);
  636.   Str (Node, NodeStr);
  637.   NodeStr := PaddedNum (Node);
  638.   TakeNode;
  639.   BroadCastAll (2, '^^0FBJ'#8'lackjack Dealer', '');
  640.   BroadCastAll (9, '', '^^89*** Blackjack'+ProgVerStr+' Game Module Active ***');
  641.   BroadCastAll (9, '', '^^0DThis program is registered to: ^^0F'+Registerdata.TheName);
  642.   If not Registered then
  643.     BroadCastAll (9, '', '^^8EBe sure to register soon!');
  644.   BroadCastAll (9, '', '^^0DType ^^0F/BJ HELP ^^0Dfor the commands.');
  645. end;
  646.  
  647. Procedure DeInit;
  648. Var
  649.   B : byte;
  650.   f : File of byte;
  651. begin
  652.   BroadCastAll (3, '^^0CThe ^^0FBlackjack Dealer','');
  653.   BroadCastAll (9, '', '^^89*** Blackjack'+ProgVerStr+' Game Module Deactivated ***');
  654.   Assign (F, IPCDir + 'NODEIDX2.RAP');
  655.   Reset (f);
  656.   Seek (f, Node - 1);
  657.   b := 0;
  658.   {$I-}
  659.   Repeat
  660.     Write (f,b);
  661.   Until IOResult = 0;
  662.   {$I+}
  663.   Close (f);
  664.   TextAttr := $07;
  665.   Window (1,1,80,25);
  666.   ClrScr;
  667. end;
  668.  
  669. Procedure InitScreen;
  670. begin
  671.   Delay (1000);
  672.   ClrScr;
  673.   TextAttr := $71;  { Grey on blue }
  674.   { Put background in, skipping the bottom line to create a status bar }
  675.   For L := 1 to 1920 do Write ('░');
  676.   TextAttr := $74;
  677.   GotoXY (1,1);   ClrEol;
  678.   GotoXY (8,1);  Writeln ('Blackjack for RAP'+ProgVerStr+' (c) 1995 by David Ong, All Rights Reserved.');
  679.   WindowBorder (5,3,74,21, White, Blue);
  680.   GotoXY (1,25);
  681.   TextAttr := $70;
  682.   Write (' Press <ESC> to deactivate blackjack');
  683.   ClrEol;
  684.   If not registered then
  685.   begin
  686.     GotoXY (67,25);
  687.     Textcolor (Red+Blink);
  688.     Textbackground (LightGray);
  689.     Write ('Unregistered');
  690.   end
  691.   else
  692.   begin
  693.     GotoXY (67,25);
  694.     Textcolor (Red);
  695.     Textbackground (LightGray);
  696.     Write ('Registered');
  697.   end;
  698.   Window (6,4,73,20);
  699.   Textbackground (Blue);
  700.   Textcolor (Yellow);
  701.   Writeln ('Waiting for people to join blackjack.');
  702. end;
  703.  
  704. Procedure InitVars;
  705. begin
  706.   For L := 1 to 255 do
  707.   begin
  708.     NodeStat[L] := 0;
  709.     NodeCD[L] := ConfigData.StartCD;
  710.     NodeHand[L] := '';
  711.     NodeHand2[L] := '';
  712.     NodeBet[L] := ConfigData.BetCD;
  713.     NodeDD[L] := 1;
  714.     NodeDD2[L] := 1;
  715.     NodeDoneH1[L] := False;
  716.     NodeDoneH2[L] := False;
  717.     NodeInsure[L] := False;
  718.   end;
  719.   UsedCards := '';
  720. end;
  721.  
  722. Function MSGWait : boolean;
  723. Var
  724.   b : byte;
  725.   f : File of byte;
  726. begin
  727.   Assign (f, IPCDir + 'CHGIDX.RAP');
  728.   Reset (f);
  729.   Seek (f, Node - 1);
  730.   {$I-}
  731.   Repeat
  732.     Read (f,b);
  733.   Until IOResult = 0;
  734.   {$I+}
  735.   MSGWait := b = 1;
  736.   Close (f);
  737. end;
  738.  
  739. Function GetCard : String;
  740. Const
  741.   Cards : Array [1..13] of Char = 'A23456789TJQK';
  742.   Kinds : Array [1..4] of Char = 'HDSC';
  743. Var
  744.   Value, Kind : Byte;
  745.   Card : String[6];
  746. begin
  747.   Repeat
  748.     Value := Random (13)+1;
  749.     Kind := Random (4)+1;
  750.     Card := Cards[Value] + Kinds [Kind];
  751.   Until Pos (Card, UsedCards) = 0;
  752.   UsedCards := UsedCards + Card;
  753.   If Length (UsedCards) > 92 then UsedCards := '';
  754.   GetCard := Card;
  755. end;
  756.  
  757. Function HandValue (Hand : String) : Byte;
  758. Var
  759.   Value : Byte;
  760.   Aces : Byte;
  761. begin
  762.   Value := 0;
  763.   { Count aces }
  764.   Aces := 0;
  765.   For L := 1 to Length (Hand) do if Hand[L] = 'A' then Inc (Aces);
  766.   While Hand[0] > #1 do
  767.   begin
  768.     If Hand[1] = 'A' then Value := Value + 11;
  769.     If Hand[1] in ['T','J','Q','K'] then Value := Value + 10;
  770.     If Hand[1] in ['2'..'9'] then Value := Value + Ord(Hand[1])-48;
  771.     Delete (Hand, 1, 2);
  772.   end;
  773.   While (Value > 21) and (Aces <> 0) do
  774.   begin
  775.     Dec (Value,10);
  776.     Dec (Aces);
  777.   end;
  778.   HandValue := Value;
  779. end;
  780.  
  781. Function ColorHand (Hand : String) : String;
  782. Var
  783.   New : String;
  784. begin
  785.   New := '';
  786.   While Hand[0] > #1 do
  787.   begin
  788.     If Hand[2] in ['D','H'] then New := New + '^^74'+Hand[1]+Hand[2]+'^^0A '
  789.     else
  790.     If Hand[2] in ['C','S'] then New := New + '^^70'+Hand[1]+Hand[2]+'^^0A '
  791.     else New := New + '^^70  ^^0A';
  792.     Delete (Hand, 1, 2);
  793.   end;
  794.   ColorHand := New;
  795. end;
  796.  
  797. Procedure NextPlayer;
  798. Var
  799.   I : Word;
  800. begin
  801.   If NodeStat[NodeTurn] <> 0 then
  802.     If NodeHand2[NodeTurn] <> '' then
  803.     begin
  804.       If (HandValue (NodeHand[NodeTurn]) > 21) and
  805.       (HandValue (NodeHand2[NodeTurn]) > 21) then NodeStat[NodeTurn] := 1;
  806.     end
  807.     else If HandValue (NodeHand[NodeTurn]) > 21 then NodeStat[NodeTurn] := 1;
  808.   If NodeStat[NodeTurn] = 1 then
  809.   begin
  810.     If NodeInsure[NodeTurn] then
  811.     begin
  812.       Dec (NodeCD[NodeTurn], Round (NodeBet[NodeTurn]/2));
  813.       GiveMSG (9, '', '^^0FYou^^8D lose ^^0Dyour insurance bet of ^^0F'+ToStr(Round(NodeBet[NodeTurn]/2))
  814.                +' ^^0DCyberdollars!', NodeTurn);
  815.       If NodeGender (NodeTurn) then
  816.         BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+'^^8D loses ^^0Dher insurance bet of ^^0F'
  817.                       +ToStr(Round(NodeBet[NodeTurn]/2))+' ^^0DCyberdollars!', NodeTurn)
  818.       else
  819.         BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+'^^8D loses ^^0Dhis insurance bet of ^^0F'
  820.                       +ToStr(Round(NodeBet[NodeTurn]/2))+' ^^0DCyberdollars!', NodeTurn)
  821.     end;
  822.   end;
  823.   I := NodeTurn;
  824.   Repeat
  825.     Inc (I);
  826.   Until (I = 256) or (NodeStat[I] = 2);
  827.   If I = 256 then NodeTurn := -1       { Dealer's turn }
  828.     else NodeTurn := I;
  829.   If NodeTurn > 1 then
  830.   begin
  831.     {$IFDEF OLDRAP}
  832.     {$ELSE}
  833.     NodeData2.TTTStart := -1;
  834.     {$ENDIF}
  835.     NodeData2.DoneTo := -1;
  836.     NodeData2.From := Node - 1;
  837.     NodeData2.Gender := 0;
  838.     NodeData2.Alias := '';
  839.     NodeData2.Kind := 9;
  840.     NodeData2.Data := '^0DIt is your turn in ^^0Fblackjack^^0D!'#0;
  841.     NodeData2.Data[0] := '^';
  842.     SendMSG (NodeTurn, NodeData2);
  843.   end;
  844.   SecPassed := 0;
  845.   If NodeTurn > 1 then Writeln ('It is ', NodeUser(NodeTurn), '''s turn in blackjack.')
  846.   else Writeln ('It is the Dealer''s turn in blackjack.');
  847. end;
  848.  
  849. Procedure DisplayHand (Node : Word);
  850. begin
  851.   GiveMSG (9, '', '^^0DDealer''s cards: '+ColorHand(DealerHand[1]+DealerHand[2])+'^^70  ^^0D  (^^0F'
  852.            +ToStr(HandValue(DealerHand[1]+DealerHand[2]))+'^^0D)', Node);
  853.   If NodeHand2[Node] <> '' then
  854.   begin
  855.     If not NodeDoneH1[Node] then
  856.     GiveMSG (9, '', '^^0DFirst hand :    '+ColorHand(NodeHand[Node])+' ^^0D(^^0F'
  857.              +ToStr(HandValue(NodeHand[Node]))+'^^0D)', Node);
  858.     If not NodeDoneH2[Node] then
  859.     GiveMSG (9, '', '^^0DSecond hand:    '+ColorHand(NodeHand2[Node])+' ^^0D(^^0F'
  860.              +ToStr(HandValue(NodeHand2[Node]))+'^^0D)', Node);
  861.   end
  862.   else
  863.     GiveMSG (9, '', '^^0DYour cards:     '+ColorHand(NodeHand[Node])+' ^^0D(^^0F'
  864.              +ToStr(HandValue(NodeHand[Node]))+'^^0D)', Node);
  865. end;
  866.  
  867. Procedure RegRemind;
  868. Var
  869.   N : Byte;
  870. begin
  871.   N := Random (4);
  872.   Case N of
  873.     0 : Broadcast (9,'','From ^^0BBlackjack Dealer^^0E, holding up a big placard: ^^0ARemember to register Blackjack!');
  874.     1 : BroadCast (9,'','^^8FThis version of Blackjack for RAP is UNREGISTERED!^^0E');
  875.     2 : BroadCast (9,'','From ^^0BBlackjack Dealer^^0E, in a hypnotic tone: ^^0ARegister blackjack, Register blackjack...');
  876.     3 : BroadCast (9,'','From ^^0BBlackjack Dealer^^0E, over the bar''s PA system: ^^0ABlackjack is UNREGISTERED!');
  877.   end;
  878. end;
  879.  
  880. Procedure Retal (Node : Word);
  881. Var
  882.   N : Byte;
  883.   J : Byte;
  884. begin
  885.   N := Random (20);
  886.   If N > 9 then
  887.   begin
  888.     J := Random (9);
  889.     Case J of
  890.     0 : begin
  891.           GiveMSG (9, '', 'The ^^0BBlackjack Dealer ^^0Eis booting ^^0Byou ^^0Eto the head!',
  892.                       Node);
  893.           BroadCastAllBut (9, '', 'The ^^0BBlackjack Dealer ^^0Eis booting ^^0B'+NodeUser(Node)+' ^^0Eto the head!', Node);
  894.         end;
  895.     1 : begin
  896.           GiveMSG (9, '', 'The ^^0BBlackjack Dealer ^^0Eis frowning darkly at ^^0Byou^^0E!',
  897.                       Node);
  898.           BroadCastAllBut (9, '', 'The ^^0BBlackjack Dealer ^^0Eis frowning darkly at ^^0B'+NodeUser(Node)+'^^0E!', Node);
  899.         end;
  900.     2 : begin
  901.           GiveMSG (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust smacked ^^0Byou ^^0Eacross the back of the head!',
  902.                       Node);
  903.           BroadCastAllBut (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust smacked ^^0B'+NodeUser(Node)
  904.                         +' ^^0Eacross the back of the head!', Node);
  905.         end;
  906.     3,4 : If NodeStat[Node] > 0 then
  907.           BroadCastAll (9, 'The Blackjack Dealer', 'From ^^0BThe Blackjack Dealer^^0E, grumbling unhappily: ^^0AStop that, '
  908.                         +NodeUser(Node)+', or I''ll kick you out of the game!');
  909.     5 : begin
  910.           GiveMSG (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust elbowed ^^0Byou ^^0Ein the face!',
  911.                       Node);
  912.           BroadCastAllBut (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust elbowed ^^0B'+NodeUser(Node)+' ^^0Ein the face!', Node);
  913.         end;
  914.     6 : BroadCastAll (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust put up ^^0Bhis^^0E deflector shields!');
  915.     7 : begin
  916.           GiveMSG (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust poked ^^0Byou ^^0Ein the ribs!',
  917.                       Node);
  918.           BroadCastAllBut (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust poked ^^0B'+NodeUser(Node)+' ^^0Ein the ribs!', Node);
  919.         end;
  920.     8 : begin
  921.           GiveMSG (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust gave ^^0Byou ^^0Ea good, swift, kick in the butt!',
  922.                       Node);
  923.           BroadCastAllBut (9, '', 'The ^^0BBlackjack Dealer ^^0Ejust gave ^^0B'+NodeUser(Node)
  924.                            +' ^^0Ea good, swift, kick in the butt!', Node);
  925.         end;
  926.     end;
  927.   end
  928.   else
  929.   If ((N = 9) or (N = 8)) and (NodeStat[NodeData.From+1] > 0) then
  930.   begin
  931.     If NodeStat[NodeData.From+1] = 2 then
  932.     begin
  933.       Dec (NodeCD[Node], NodeBet[Node]*NodeDD[Node]);
  934.       If (NodeHand2[Node] <> '') and (HandValue (NodeHand2[Node]) < 22) then
  935.         Dec (NodeCD[Node], NodeBet[Node]*NodeDD2[Node]);
  936.       If NodeInsure[Node] then Dec (NodeCD[Node], Round(NodeBet[Node]/2));
  937.     end;
  938.     NodeStat[Node] := 0;
  939.     BroadCastBut (9,'','^^0DThe ^^0Fblackjack dealer ^^0Djust tossed ^^0F'+(NodeUser(Node))
  940.                   +' ^^0Dout of the ^^0Fblackjack^^0D game!', Node);
  941.     GiveMSG (9,'','^^0DThe angry ^^0Fblackjack dealer ^^0Djust tossed ^^0Fyou ^^0Dout of the ^^0Fblackjack^^0D game!',
  942.                   Node);
  943.     Writeln (NodeUser(Node), ' is dealt out of the blackjack game.');
  944.     If (NodeData.From+1) = NodeTurn then NextPlayer;
  945.   end;
  946. end;
  947.  
  948. Procedure Process (NodeData : NodeRec);
  949. Var
  950.   s : String;
  951.   I : Word;
  952.   L : LongInt;
  953.   Error : Integer;
  954.   J : Word;
  955. begin
  956.   {$IFDEF OLDRAP}
  957.   {$ELSE}
  958.   NodeData2.TTTStart := -1;
  959.   {$ENDIF}
  960.   NodeData2.DoneTo := -1;
  961.   NodeData2.From := Node - 1;
  962.   NodeData2.Gender := 0;
  963.   NodeData2.Alias := '';
  964.   NodeData2.Kind := 9;
  965.   If NodeData.Kind = 6 then
  966.   begin
  967.     s := KillSpaces(UpStr(CStr(NodeData.Data)));
  968.     If s = 'ON' then
  969.     begin
  970.       If NodeStat[NodeData.From+1] = 0 then
  971.       begin
  972.         GiveMSG (9, '', '^^0DOk, you will now be playing in the next ^^0Fblackjack ^^0Dgame!',
  973.                  NodeData.From+1);
  974.         NodeStat[NodeData.From+1] := 1;
  975.         BroadCastBut (9,'','^^0F'+CStr(NodeData.Alias)+' ^^0Dwill be playing in the next ^^0Fblackjack^^0D game!',
  976.                       NodeData.From+1);
  977.         Writeln (CStr(NodeData.Alias), ' joins the blackjack game.');
  978.       end
  979.       else
  980.         GiveMSG (9, '', '^^0DYou are already playing ^^0Fblackjack^^0D!', NodeData.From+1);
  981.     end;
  982.     If s = 'OFF' then
  983.     begin
  984.       If NodeStat[NodeData.From+1] = 0 then
  985.         GiveMSG (9, '', '^^0DYou aren''t playing in ^^0Fblackjack^^0D!', NodeData.From+1)
  986.       else
  987.       begin
  988.         GiveMSG (9, '', '^^0DOk, you are no longer playing ^^0Fblackjack^^0D.', NodeData.From+1);
  989.         If NodeStat[NodeData.From+1] = 2 then
  990.         begin
  991.           Dec (NodeCD[NodeData.From+1], NodeBet[NodeData.From+1]*NodeDD[NodeData.From+1]);
  992.           NextPlayer;
  993.         end;
  994.         BroadCastBut (9,'','^^0F'+CStr(NodeData.Alias)+' ^^0Dask to be dealt out of the ^^0Fblackjack^^0D game!',
  995.                       NodeData.From+1);
  996.         Writeln (CStr(NodeData.Alias), ' is dealt out of the blackjack game.');
  997.         NodeStat[NodeData.From+1] := 0;
  998.       end;
  999.     end;
  1000.     If (s='INSURE')or(s='INSURANCE')or(s='INSUR')or(s='INS')or(s='INSUER') then
  1001.     begin
  1002.       If (NodeStat[NodeData.From+1] = 2) then
  1003.       begin
  1004.         If NodeData.From+1 = NodeTurn then
  1005.         begin
  1006.           If NodeInsure[NodeData.From+1] then
  1007.             GiveMSG (9, '', '^^0DYou''ve already made an insurance bet!', NodeData.From+1)
  1008.           else
  1009.           begin
  1010.             If (Length (NodeHand[NodeData.From+1]) = 4) and (NodeHand2[NodeData.From+1]='') then
  1011.             begin
  1012.               GiveMSG (9, '', '^^0DOk, you make an insurance bet.', NodeData.From+1);
  1013.               BroadcastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dmakes an insurance bet.', NodeData.From+1);
  1014.               NodeInsure[NodeData.From+1] := True;
  1015.             end
  1016.             else GiveMSG (9, '', '^^0DYou can''t buy insurance now!', NodeData.From+1);
  1017.           end;
  1018.         end
  1019.         else
  1020.           GiveMSG (9, '', '^^0DIt isn''t your turn!', NodeData.From+1);
  1021.       end
  1022.       else
  1023.         GiveMSG (9, '', '^^0DYou aren''t playing in the ^^0Fblackjack^^0D game.', NodeData.From+1);
  1024.     end;
  1025.     If (s='STAY')or(s='STA')or(s='STY')or(s='SAY')or(s='TAY')or(s='STYA')or(s='STAYU')or
  1026.        (s='STAND') then
  1027.     begin
  1028.       If (NodeStat[NodeData.From+1] = 2) then
  1029.       begin
  1030.         If NodeData.From+1 = NodeTurn then
  1031.         begin
  1032.           GiveMSG (9, '', '^^0DOk, you stay.', NodeData.From+1);
  1033.           BroadcastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dstays.', NodeData.From+1);
  1034.           NextPlayer;
  1035.         end
  1036.         else
  1037.           GiveMSG (9, '', '^^0DIt isn''t your turn!', NodeData.From+1);
  1038.       end
  1039.       else
  1040.         GiveMSG (9, '', '^^0DYou aren''t playing in the ^^0Fblackjack^^0D game.', NodeData.From+1);
  1041.     end;
  1042.     If (s='HAND')or(s='HAN')or(s='HADN')or(s='AHND') then
  1043.     begin
  1044.       If NodeStat[NodeData.From+1] = 2 then DisplayHand (NodeData.From+1)
  1045.       else
  1046.         GiveMSG (9, '', '^^0DYou aren''t playing in the ^^0Fblackjack^^0D game.', NodeData.From+1);
  1047.     end;
  1048.     If (s = 'CD') or (s = '$') then
  1049.       GiveMSG (9, '', '^^0DYou have ^^0F'+ ToStr(NodeCD[NodeData.From+1])+'^^0D Cyberdollars.', NodeData.From+1);
  1050.     If (s='HIT')or(s='HIT1')or(s='HTI')or(s='IHT') then
  1051.     begin
  1052.       If NodeStat[NodeData.From+1] = 2 then
  1053.       begin
  1054.         If NodeData.From+1 = NodeTurn then
  1055.         begin
  1056.           If NodeDoneH1[NodeData.From+1] then GiveMSG (9, '', '^^0DYou can''t play that hand!', NodeData.From+1)
  1057.           else
  1058.           begin
  1059.             BroadcastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dhits.', NodeData.From+1);
  1060.             NodeHand[NodeData.From+1] := NodeHand[NodeData.From+1] + GetCard;
  1061.             DisplayHand (NodeData.From+1);
  1062.             SecPassed := 0;
  1063.             Writeln (NodeUser(NodeTurn), ' hits.');
  1064.             If HandValue(NodeHand[NodeData.From+1]) > 21 then
  1065.             begin
  1066.               GiveMSG (9, '', '^^8DYou busted!', NodeData.From+1);
  1067.               BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dbusts!', NodeData.From+1);
  1068.               BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+'^^8D loses ^^0F'+ToStr(NodeBet[NodeTurn])+' ^^0DCyberdollars!'
  1069.                             , NodeData.From+1);
  1070.               GiveMSG (9, '', '^^0FYou^^8D lose ^^0F'+ToStr(NodeBet[NodeTurn])+' ^^0DCyberdollars!', NodeData.From+1);
  1071.               Dec (NodeCD[NodeData.From+1], NodeBet[NodeData.From+1]);
  1072.               Writeln (NodeUser(NodeTurn), ' busts.');
  1073.               NodeDoneH1[NodeData.From+1] := True;
  1074.               If NodeHand2[NodeData.From+1] = '' then NextPlayer
  1075.               else If NodeDoneH1[NodeData.From+1] and NodeDoneH2[NodeData.From+1] then NextPlayer;
  1076.             end;
  1077.           end;
  1078.         end
  1079.         else
  1080.           GiveMSG (9, '', '^^0DIt is not your turn!', NodeData.From+1);
  1081.       end
  1082.       else
  1083.         GiveMSG (9, '',  '^^0DYou aren''t playing in the ^^0Fblackjack^^0D game.', NodeData.From+1);
  1084.     end;
  1085.     If (s='HIT2')or(s='HTI2')or(s='HI2T')or(s='IHT2') then
  1086.     begin
  1087.       If NodeStat[NodeData.From+1] = 2 then
  1088.       begin
  1089.         If NodeData.From+1 = NodeTurn then
  1090.         begin
  1091.           If NodeHand2[NodeData.From+1] = '' then
  1092.             GiveMSG (9, '', '^^0DYou don''t have a second hand!', NodeData.From+1)
  1093.           else
  1094.           begin
  1095.             If NodeDoneH2[NodeData.From+1] then GiveMSG (9, '', '^^0DYou can''t play that hand!', NodeData.From+1)
  1096.             else
  1097.             begin
  1098.               BroadcastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dhits second hand.', NodeData.From+1);
  1099.               NodeHand2[NodeData.From+1] := NodeHand2[NodeData.From+1] + GetCard;
  1100.               DisplayHand (NodeData.From+1);
  1101.               SecPassed := 0;
  1102.               Writeln (NodeUser(NodeTurn), ' hits second hand.');
  1103.               If HandValue(NodeHand2[NodeData.From+1]) > 21 then
  1104.               begin
  1105.                 GiveMSG (9, '', '^^8DYou busted!', NodeData.From+1);
  1106.                 BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dbusts!', NodeData.From+1);
  1107.                 BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+'^^8D loses ^^0F'+ToStr(NodeBet[NodeTurn])+' ^^0DCyberdollars!'
  1108.                               , NodeData.From+1);
  1109.                 GiveMSG (9, '', '^^0FYou^^8D lose ^^0F'+ToStr(NodeBet[NodeTurn])+' ^^0DCyberdollars!', NodeData.From+1);
  1110.                 Dec (NodeCD[NodeData.From+1], NodeBet[NodeData.From+1]);
  1111.                 Writeln (NodeUser(NodeTurn), ' busts.');
  1112.                 NodeDoneH2[NodeData.From+1] := True;
  1113.                 If NodeDoneH1[NodeData.From+1] and NodeDoneH2[NodeData.From+1] then NextPlayer;
  1114.               end;
  1115.             end;
  1116.           end;
  1117.         end
  1118.         else
  1119.           GiveMSG (9, '', '^^0DIt is not your turn!', NodeData.From+1);
  1120.       end
  1121.       else
  1122.         GiveMSG (9, '',  '^^0DYou aren''t playing in the ^^0Fblackjack^^0D game.', NodeData.From+1);
  1123.     end;
  1124.     If (s = 'HELP') or (s = '!') or (s = '?') or (s = 'COMMANDS') then
  1125.     begin
  1126.       For I := 1 to 15 do
  1127.         GiveMSG (9, '', HelpData[I], NodeData.From+1);
  1128.     end;
  1129.     If (s='SPLIT')or(s='SPLI')or(s='SPL')or(s='SPLITT')or(s='SPLTI') then
  1130.     begin
  1131.       If NodeStat[NodeData.From+1] = 2 then
  1132.         If NodeData.From+1 = NodeTurn then
  1133.         begin
  1134.           If (Length (NodeHand[NodeData.From+1]) = 4) and (NodeHand2[NodeData.From+1] = '') then
  1135.           begin
  1136.             If HandValue (NodeHand[NodeData.From+1][1]+NodeHand[NodeData.From+1][2])
  1137.                = HandValue (NodeHand[NodeData.From+1][3]+NodeHand[NodeData.From+1][4]) then
  1138.             begin
  1139.               GiveMSG (9, '', '^^0DOk, you split.', NodeData.From+1);
  1140.               SecPassed := 0;
  1141.               BroadcastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dsplits.', NodeData.From+1);
  1142.               NodeHand2[NodeData.From+1] := NodeHand[NodeData.From+1][3]+NodeHand[NodeData.From+1][4];
  1143.               Dec (NodeHand[NodeData.From+1][0], 2);
  1144.               NodeHand[NodeData.From+1] := NodeHand[NodeData.From+1] + GetCard;
  1145.               NodeHand2[NodeData.From+1] := NodeHand2[NodeData.From+1] + GetCard;
  1146.               DisplayHand (NodeData.From+1);
  1147.             end
  1148.             else GiveMSG (9, '', '^^0DYou can''t split when card values are different!', NodeData.From+1)
  1149.           end
  1150.           else GiveMSG (9, '', '^^0DYou can''t split now!', NodeData.From+1)
  1151.         end
  1152.         else
  1153.           GiveMSG (9, '', '^^0DIt is not your turn!', NodeData.From+1)
  1154.       else
  1155.         GiveMSG (9, '',  '^^0DYou aren''t playing in the ^^0Fblackjack^^0D game.', NodeData.From+1);
  1156.     end;
  1157.     If (s='DOUBLE')or(s='DOUBLEDOWN')or(s = 'DD')or(s='DOUBLE1')or(s='DOUBLEDOWN1')or(s='DD1')or
  1158.        (s='DOUBL')or(s='DOUBLEE')or(s='DOUB')or(s='DOUBEL')or(s='DUOBLE')or(s='DOUBKLE') then
  1159.     begin
  1160.       If NodeStat[NodeData.From+1] = 2 then
  1161.       begin
  1162.         If NodeData.From+1 = NodeTurn then
  1163.         begin
  1164.           BroadcastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Ddoubles down.', NodeData.From+1);
  1165.           NodeHand[NodeData.From+1] := NodeHand[NodeData.From+1] + GetCard;
  1166.           NodeDD[NodeData.From+1] := 2;
  1167.           GiveMSG (9, '', '^^0DOk, you ^^0Fdouble down^^0D!', NodeData.From+1);
  1168.           DisplayHand (NodeData.From+1);
  1169.           SecPassed := 0;
  1170.           Writeln (NodeUser(NodeTurn), ' doubles down.');
  1171.           If HandValue(NodeHand[NodeData.From+1]) > 21 then
  1172.           begin
  1173.             GiveMSG (9, '', '^^8DYou busted!', NodeData.From+1);
  1174.             BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dbusts!', NodeData.From+1);
  1175.             BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+'^^8D loses ^^0F'+ToStr(NodeBet[NodeTurn]*NodeDD[NodeTurn])
  1176.                           +' ^^0DCyberdollars!', NodeData.From+1);
  1177.             GiveMSG (9, '', '^^0FYou^^8D lose ^^0F'+ToStr(NodeBet[NodeTurn]*NodeDD[NodeTurn])+' ^^0DCyberdollars!',
  1178.                      NodeData.From+1);
  1179.             Dec (NodeCD[NodeData.From+1], NodeBet[NodeData.From+1]*NodeDD[NodeData.From+1]);
  1180.             Writeln (NodeUser(NodeTurn), ' busts.');
  1181.           end;
  1182.           NodeDoneH1[NodeData.From+1] := True;
  1183.           If NodeHand2[NodeData.From+1] = '' then NextPlayer
  1184.           else If NodeDoneH1[NodeData.From+1] and NodeDoneH2[NodeData.From+1]
  1185.             then NextPlayer;
  1186.         end
  1187.         else
  1188.           GiveMSG (9, '', '^^0DIt is not your turn!', NodeData.From+1);
  1189.       end
  1190.       else
  1191.         GiveMSG (9, '',  '^^0DYou aren''t playing in the ^^0Fblackjack^^0D game.', NodeData.From+1);
  1192.     end;
  1193.     If (s = 'DOUBLE2') or (s = 'DOUBLEDOWN2') or (s = 'DD2') then
  1194.     begin
  1195.       If NodeStat[NodeData.From+1] = 2 then
  1196.       begin
  1197.         If NodeData.From+1 = NodeTurn then
  1198.         begin
  1199.           If NodeHand2[NodeData.From+1] = '' then
  1200.             GiveMSG (9, '', '^^0DYou don''t have a second hand!', NodeData.From+1)
  1201.           else
  1202.           begin
  1203.             BroadcastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Ddoubles down on second hand.', NodeData.From+1);
  1204.             NodeHand2[NodeData.From+1] := NodeHand2[NodeData.From+1] + GetCard;
  1205.             NodeDD2[NodeData.From+1] := 2;
  1206.             GiveMSG (9, '', '^^0DOk, you ^^0Fdouble down^^0D!', NodeData.From+1);
  1207.             DisplayHand (NodeData.From+1);
  1208.             SecPassed := 0;
  1209.             Writeln (NodeUser(NodeTurn), ' doubles down on second hand.');
  1210.             If HandValue(NodeHand2[NodeData.From+1]) > 21 then
  1211.             begin
  1212.               GiveMSG (9, '', '^^8DYou busted!', NodeData.From+1);
  1213.               BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+' ^^0Dbusts!', NodeData.From+1);
  1214.               BroadCastBut (9, '', '^^0F'+NodeUser(NodeTurn)+'^^8D loses ^^0F'+ToStr(NodeBet[NodeTurn]*NodeDD2[NodeTurn])
  1215.                             +' ^^0DCyberdollars!', NodeData.From+1);
  1216.               GiveMSG (9, '', '^^0FYou^^8D lose ^^0F'+ToStr(NodeBet[NodeTurn]*NodeDD2[NodeTurn])+' ^^0DCyberdollars!',
  1217.                        NodeData.From+1);
  1218.               Dec (NodeCD[NodeData.From+1], NodeBet[NodeData.From+1]*NodeDD2[NodeData.From+1]);
  1219.               Writeln (NodeUser(NodeTurn), ' busts.');
  1220.             end;
  1221.             NodeDoneH2[NodeData.From+1] := True;
  1222.             If NodeDoneH1[NodeData.From+1] and NodeDoneH2[NodeData.From+1] then NextPlayer;
  1223.           end
  1224.         end
  1225.         else
  1226.           GiveMSG (9, '', '^^0DIt is not your turn!', NodeData.From+1);
  1227.       end
  1228.       else
  1229.         GiveMSG (9, '',  '^^0DYou aren''t playing in the ^^0Fblackjack^^0D game.', NodeData.From+1);
  1230.     end;
  1231.     If (s='TURN')or(s='TUR')or(s='TUNR') then
  1232.     begin
  1233.       If GamePlaying then
  1234.       begin
  1235.         If NodeTurn = NodeData.From+1 then
  1236.           GiveMSG (9, '', '^^0DIt is ^^0Fyour ^^0Dturn in blackjack.',
  1237.                    NodeData.From+1)
  1238.         else
  1239.           GiveMSG (9, '', '^^0DIt is ^^0F'+NodeUser(NodeTurn)+'^^0D''s turn in blackjack.',
  1240.                    NodeData.From+1);
  1241.       end
  1242.       else
  1243.         GiveMSG (9, '', '^^0DThere is no blackjack game being played at the moment.', NodeData.From+1);
  1244.     end;
  1245.     If (s='SCAN')or(s='SCA')or(s='SCNA') then
  1246.     begin
  1247.       GiveMSG (9, '', #13#10'^^0EPlayer                          Playing    Cyberdollars', NodeData.From+1);
  1248.       GiveMSG (9, '', '^^0E-------------------------------------------------------', NodeData.From+1);
  1249.       For I := 1 to 255 do
  1250.       begin
  1251.         If NodeStat[I] = 1 then
  1252.           GiveMSG (9, '', '^^0E'+NodeUser(I)+Spaces(34-Length(KillRAPCodes(NodeUser(I)))) +' No         '+ToStr(NodeCD[I]),
  1253.                    NodeData.From+1);
  1254.         If NodeStat[I] = 2 then
  1255.           GiveMSG (9, '', '^^0E'+NodeUser(I)+Spaces(34-Length(KillRAPCodes(NodeUser(I)))) +'Yes         '+ToStr(NodeCD[I]),
  1256.                    NodeData.From+1);
  1257.       end;
  1258.       GiveMSG (9, '', #0, NodeData.From+1);
  1259.     end;
  1260.     If (s='BET')or(s='BTE') then
  1261.       GiveMSG (9, '', '^^0DYour current bet is ^^0F'+ToStr(NodeBet[NodeData.From+1])+' ^^0DCyberdollars.', NodeData.From+1)
  1262.     else
  1263.     If (s[1] = 'B') and (s[2] = 'E') and (s[3] = 'T') and (s[0] > #3) then
  1264.     begin
  1265.       If NodeStat[NodeData.From+1] < 2 then
  1266.       begin
  1267.         Delete (s, 1, 3);
  1268.         Val (s, L, Error);
  1269.         If (Error <> 0) or (L > ConfigData.MaxBet) or (L < ConfigData.MinBet) then
  1270.         begin
  1271.           GiveMSG (9, '', '^^0DBets must be between ^^0F'+ToStr(ConfigData.MinBet)+' ^^0Dand ^^0F'+ToStr(ConfigData.MaxBet)+
  1272.                    ' ^^0DCyberdollars.', NodeData.From+1);
  1273.         end
  1274.         else
  1275.         begin
  1276.           NodeBet[NodeData.From+1] := L;
  1277.           GiveMSG (9, '', '^^0DOk, your bet will now be ^^0F'+ToStr(L)+' ^^0DCyberdollars.', NodeData.From+1);
  1278.         end;
  1279.       end
  1280.       else
  1281.         GiveMSG (9, '', '^^0DSorry, you cannot change your bet during a game.', NodeData.From+1);
  1282.     end;
  1283.   end;
  1284.   If (NodeData.Kind = 3) or (NodeData.Kind = 19) then
  1285.   begin
  1286.     If NodeStat[NodeData.From+1] = 2 then
  1287.     begin
  1288.       Dec (NodeCD[NodeData.From+1], NodeBet[NodeData.From+1]*NodeDD[NodeData.From+1]);
  1289.       If (NodeHand2[Node] <> '') and (HandValue (NodeHand2[Node]) < 22) then
  1290.         Dec (NodeCD[Node], NodeBet[Node]*NodeDD2[Node]);
  1291.       If NodeInsure[Node] then Dec (NodeCD[Node], Round(NodeBet[Node]/2));
  1292.       NodeStat[NodeData.From+1] := 0;
  1293.       BroadCastBut (9,'','^^0F'+CStr(NodeData.Alias)+' ^^0Dis dealt out of the ^^0Fblackjack^^0D game!',
  1294.                     NodeData.From+1);
  1295.       Writeln (CStr(NodeData.Alias), ' is dealt out of the blackjack game.');
  1296.       If (NodeData.From+1) = NodeTurn then NextPlayer;
  1297.     end;
  1298.     NodeCD[NodeData.From+1] := ConfigData.StartCD;
  1299.     NodeBet[NodeData.From+1] := ConfigData.BetCD;
  1300.   end;
  1301.   If (NodeData.Kind = 1) then
  1302.   begin
  1303.     s := UpStr(CStr(NodeData.Data));
  1304.     For J := 1 to 16 do
  1305.       If s = ComList[J] then GiveMSG (6, '^^0FThe blackjack dealer', 'You missed a "^^0A/^^0E" in your blackjack command.'
  1306.                                       , NodeData.From+1);
  1307.   end;
  1308.   If (NodeData.Kind = 10) and (NodeData.DoneTo+1 = Node) then
  1309.   begin
  1310.     s := CStr(NodeData.Data);
  1311.     If Pos ('just barfed ALL OVER', s) <> 0 then Retal (NodeData.From+1);
  1312.     If Pos ('just bonked',s) <> 0 then Retal (NodeData.From+1);
  1313.     If Pos ('is booting',s) <> 0 then Retal (NodeData.From+1);
  1314.     If Pos ('with a disruptor!',s) <> 0 then Retal (NodeData.From+1);
  1315.     If Pos ('just tossed a grenade!',s) <> 0 then Retal (NodeData.From+1);
  1316.     If Pos ('is hitting',s) <> 0 then Retal (NodeData.From+1);
  1317.     If Pos ('is kicking the life out of',s) <> 0 then Retal (NodeData.From+1);
  1318.     If Pos ('with a mushroom cloud!',s) <> 0 then Retal (NodeData.From+1);
  1319.     If Pos ('a phaser and blasted',s) <> 0 then Retal (NodeData.From+1);
  1320.     If Pos ('is punching',s) <> 0 then Retal (NodeData.From+1);
  1321.     If Pos ('just shot',s) <> 0 then Retal (NodeData.From+1);
  1322.     If Pos ('just slapped',s) <> 0 then Retal (NodeData.From+1);
  1323.     If Pos ('across the back of the head!',s) <> 0 then Retal (NodeData.From+1);
  1324.     If Pos ('just spit on',s) <> 0 then Retal (NodeData.From+1);
  1325.     If Pos ('is stripping',s) <> 0 then Retal (NodeData.From+1);
  1326.     If Pos ('just zapped',s) <> 0 then Retal (NodeData.From+1);
  1327.     If Pos ('just bashed',s) <> 0 then Retal (NodeData.From+1);
  1328.     If Pos ('just stapled',s) <> 0 then Retal (NodeData.From+1);
  1329.     If Pos ('just killed',s) <> 0 then Retal (NodeData.From+1);
  1330.     If Pos ('just elbowed',s) <> 0 then Retal (NodeData.From+1);
  1331.     If Pos ('just poked',s) <> 0 then Retal (NodeData.From+1);
  1332.   end;
  1333. end;
  1334.  
  1335. Procedure GetMSGs;
  1336. Var
  1337.   b : byte;
  1338.   z : byte;
  1339.   f : file of byte;
  1340.   NodeFile : File of NodeRec;
  1341. begin
  1342.   z := 0;
  1343.   Assign (f, IPCDir + 'MIDX'+NodeStr+'.RAP');
  1344.   Assign (NodeFile, IPCDir + 'NODE'+NodeStr+'.RAP');
  1345.   Reset (f);
  1346.   Reset (NodeFile);
  1347.   Repeat
  1348.     {$I-}
  1349.     Repeat
  1350.       Read (f,b);
  1351.     Until IOResult = 0;
  1352.     Seek (f, FilePos (f) - 1);
  1353.     Repeat
  1354.       Write (f,z);
  1355.     Until IOResult = 0;
  1356.     Repeat
  1357.       Read (NodeFile, NodeData);
  1358.     Until IOResult = 0;
  1359.     {$I+}
  1360.     If b = 1 then Process (NodeData);
  1361.   Until Eof (f);
  1362.   Close (f);
  1363.   Close (NodeFile);
  1364.   b := 0;
  1365.   Assign (f, IPCDir + 'CHGIDX.RAP');
  1366.   Reset (f);
  1367.   Seek (f, Node - 1);
  1368.   {$I-}
  1369.   Repeat
  1370.     Write (f,b);
  1371.   Until IOResult = 0;
  1372.   {$I+}
  1373.   Close (f);
  1374. end;
  1375.  
  1376. Procedure WaitSec;
  1377. begin
  1378.   GetTime (L, L, OldSec, L);
  1379.   Repeat
  1380.     GetTime (L, L, Sec, L);
  1381.   Until Sec <> OldSec;
  1382.   OldSec := Sec;
  1383.   Inc (SecPassed);
  1384. end;
  1385.  
  1386. Procedure StartGame;
  1387. Var
  1388.   SomeoneIn : Boolean;
  1389.   I : Word;
  1390. begin
  1391.   Writeln ('Starting a new blackjack game');
  1392.  { UsedCards := ''; }
  1393.   {$IFDEF OLDRAP}
  1394.   {$ELSE}
  1395.   NodeData2.TTTStart := -1;
  1396.   {$ENDIF}
  1397.   NodeData2.DoneTo := -1;
  1398.   NodeData2.From := Node - 1;
  1399.   NodeData2.Gender := 0;
  1400.   NodeData2.Alias := '';
  1401.   NodeData2.Kind := 9;
  1402.   SomeoneIn := False;
  1403.   { Get dealer's hand }
  1404.   DealerHand := GetCard + GetCard;
  1405.   If (Random(5) = 0) and (not registered) then RegRemind;
  1406.   For I := 1 to 255 do
  1407.     If NodeStat[I] > 0 then
  1408.     begin
  1409.       SomeoneIn := True;
  1410.       GiveMSG (9, '', #0, I);
  1411.       GiveMSG (9, '', '^^0DA new ^^0Fblackjack ^^0Dgame has begun!', I);
  1412.       NodeStat[I] := 2;
  1413.     end;
  1414.   { Deal first cards }
  1415.   For I := 1 to 255 do
  1416.     If NodeStat[I] = 2 then
  1417.     begin
  1418.       NodeHand[I] := GetCard + GetCard;
  1419.       GiveMSG (9, '', '^^0DDealer''s cards: '+ColorHand(DealerHand[1]+DealerHand[2])+'^^70  ^^0D  (^^0F'
  1420.                +ToStr(HandValue(DealerHand[1]+DealerHand[2]))+'^^0D)', I);
  1421.       GiveMSG (9, '', '^^0DYour cards:     '+ColorHand(NodeHand[I])+' ^^0D(^^0F'+ToStr(HandValue(NodeHand[I]))+'^^0D)', I);
  1422.       If DealerHand[1] = 'A' then GiveMSG (9, '',
  1423.         '^^0DDealer has possible blackjack, you may want to make an insurance bet.', I);
  1424.     end;
  1425.   If SomeoneIn then
  1426.   begin
  1427.     For I := 255 downto 1 do If NodeStat[I] = 2 then NodeTurn := I;
  1428.     GamePlaying := True;
  1429.     GiveMSG (9, '', '^^0DIt is your turn in ^^0Fblackjack^^0D!', NodeTurn);
  1430.     Writeln ('It is ', NodeUser(NodeTurn), '''s turn in blackjack.');
  1431.   end
  1432.   else Writeln ('No players.');
  1433.   SecPassed := 0;
  1434. end;
  1435.  
  1436. Procedure WarnUser;
  1437. begin
  1438.   GiveMSG (9, '', #7'^^8DIt is still your turn in ^^8Fblackjack^^8D!', NodeTurn);
  1439.   WaitSec;
  1440. end;
  1441.  
  1442. Procedure DealerPlay;
  1443. Var
  1444.   I : Word;
  1445.   DealerValue : Word;
  1446. begin
  1447.   BroadCast (9, '', '');
  1448.   BroadCast (9, '', '^^0DThe ^^0FBlackjack dealer ^^0Dnow plays.');
  1449.   WaitSec;
  1450.   BroadCast (9, '', '^^0DDealer''s cards: '+ColorHand(DealerHand)+' ^^0D(^^0F'+ToStr(HandValue(DealerHand))+'^^0D)');
  1451.   WaitSec;
  1452.   While HandValue (DealerHand) < 17 do
  1453.   begin
  1454.     Writeln ('Dealer hits.');
  1455.     BroadCast (9, '', '^^0FDealer ^^0Dhits.');
  1456.     DealerHand := DealerHand + GetCard;
  1457.     WaitSec;
  1458.     BroadCast (9, '', '^^0DDealer''s cards: '+ColorHand(DealerHand)+' ^^0D(^^0F'+ToStr(HandValue(DealerHand))+'^^0D)');
  1459.     WaitSec;
  1460.   end;
  1461.   WaitSec;
  1462.   If HandValue (DealerHand) < 22 then BroadCast (9, '', '^^0FDealer ^^0Dstays.'#13#10)
  1463.   else BroadCast (9, '', '^^0FDealer ^^0Dbusts!'#13#10);
  1464.   BroadCast (9, '', '^^0DThe ^^0Fblackjack ^^0Dgame is over!');
  1465.  
  1466.   { Pay the winners }
  1467.   DealerValue := HandValue (DealerHand);
  1468.   If DealerValue > 21 then DealerValue := 0;
  1469.   If (DealerValue = 21) and (Length (DealerHand) = 4) then
  1470.   begin
  1471.     { Blackjack for dealer }
  1472.     BroadCast (9, '', '^^0DThe ^^0Fdealer ^^0Dhas a ^^8Fblackjack^^0D!');
  1473.     For I := 1 to 255 do if NodeStat[I] = 2 then
  1474.     begin
  1475.       If NodeInsure[I] then
  1476.       begin
  1477.         Inc (NodeCD[I], Round (NodeBet[I]));
  1478.         GiveMSG (9, '', '^^0FYou^^8D win ^^0Dyour insurance bet and get ^^0F'+ToStr(Round(NodeBet[I]))
  1479.                  +' ^^0DCyberdollars!', I);
  1480.         If NodeGender (I) then
  1481.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D wins ^^0Dher insurance bet and gets ^^0F'
  1482.                         +ToStr(Round(NodeBet[I]))+' ^^0DCyberdollars!', I)
  1483.         else
  1484.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D wins ^^0Dhis insurance bet and gets ^^0F'
  1485.                         +ToStr(Round(NodeBet[I]))+' ^^0DCyberdollars!', I)
  1486.       end;
  1487.       If (HandValue (NodeHand[I]) = 21) and (Length(NodeHand[I]) = 4) then
  1488.       begin
  1489.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D''s cards: '+ColorHand(NodeHand[I])+
  1490.                    ' ^^0D(^^0F'+ToStr(HandValue(NodeHand[I]))+'^^0D)', I);
  1491.         GiveMSG (9, '', '^^0FYour^^0D cards: '+ColorHand(NodeHand[I])+
  1492.                    ' ^^0D(^^0F'+ToStr(HandValue(NodeHand[I]))+'^^0D)', I);
  1493.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D loses nothing.',I);
  1494.         GiveMSG (9, '', '^^0FYou^^0D lose nothing.',I);
  1495.       end
  1496.       else
  1497.       begin
  1498.         If HandValue (NodeHand[I]) < 22 then
  1499.         begin
  1500.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D''s cards: '+ColorHand(NodeHand[I])+
  1501.                         ' ^^0D(^^0F'+ToStr(HandValue(NodeHand[I]))+'^^0D)', I);
  1502.           GiveMSG (9, '', '^^0FYour^^0D cards: '+ColorHand(NodeHand[I])+
  1503.                   ' ^^0D(^^0F'+ToStr(HandValue(NodeHand[I]))+'^^0D)', I);
  1504.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D loses ^^0F'+ToStr(NodeBet[I]*NodeDD[I])+' ^^0DCyberdollars!',I);
  1505.           GiveMSG (9, '', '^^0FYou^^8D lose ^^0F'+ToStr(NodeBet[I]*NodeDD[I])+' ^^0DCyberdollars!',I);
  1506.           Dec (NodeCD[I], NodeBet[I]*NodeDD[I]);
  1507.         end;
  1508.       end;
  1509.       If (HandValue (NodeHand2[I]) = 21) and (Length(NodeHand2[I]) = 4) and
  1510.          (NodeHand2[I] <> '') then
  1511.       begin
  1512.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D''s second hand: '+ColorHand(NodeHand2[I])+
  1513.                    ' ^^0D(^^0F'+ToStr(HandValue(NodeHand2[I]))+'^^0D)', I);
  1514.         GiveMSG (9, '', '^^0FYour^^0D second hand: '+ColorHand(NodeHand2[I])+
  1515.                    ' ^^0D(^^0F'+ToStr(HandValue(NodeHand2[I]))+'^^0D)', I);
  1516.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D loses nothing.',I);
  1517.         GiveMSG (9, '', '^^0FYou^^0D lose nothing.',I);
  1518.       end
  1519.       else
  1520.       begin
  1521.         If (NodeHand2[I] <> '') and (HandValue (NodeHand2[I]) < 22) then
  1522.         begin
  1523.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D''s second hand: '+ColorHand(NodeHand2[I])+
  1524.                      ' ^^0D(^^0F'+ToStr(HandValue(NodeHand2[I]))+'^^0D)', I);
  1525.           GiveMSG (9, '', '^^0FYour^^0D second hand: '+ColorHand(NodeHand2[I])+
  1526.                      ' ^^0D(^^0F'+ToStr(HandValue(NodeHand2[I]))+'^^0D)', I);
  1527.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D loses ^^0F'+ToStr(NodeBet[I]*NodeDD2[I])+' ^^0DCyberdollars!',I);
  1528.           GiveMSG (9, '', '^^0FYou^^8D lose ^^0F'+ToStr(NodeBet[I]*NodeDD2[I])+' ^^0DCyberdollars!',I);
  1529.           Dec (NodeCD[I], NodeBet[I]*NodeDD2[I]);
  1530.         end;
  1531.       end;
  1532.     end;
  1533.   end
  1534.   else
  1535.   For I := 1 to 255 do if NodeStat[I] = 2 then
  1536.   begin
  1537.     If HandValue (NodeHand[I]) < 22 then
  1538.     begin
  1539.       BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D''s cards: '+ColorHand(NodeHand[I])+
  1540.                  ' ^^0D(^^0F'+ToStr(HandValue(NodeHand[I]))+'^^0D)', I);
  1541.       GiveMSG (9, '', '^^0FYour^^0D cards: '+ColorHand(NodeHand[I])+
  1542.                  ' ^^0D(^^0F'+ToStr(HandValue(NodeHand[I]))+'^^0D)', I);
  1543.       If (HandValue (NodeHand[I]) = 21) and (Length (NodeHand[I]) = 4) then
  1544.       begin
  1545.         { Blackjack }
  1546.         GiveMSG (9, '', '^^8DYou got a ^^8Fblackjack^^8D!', I);
  1547.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+' ^^0Dhas a ^^0Fblackjack^^0D!', I);
  1548.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D wins ^^0F'+ToStr(Round(NodeBet[I]*(3/2)))
  1549.                           +' ^^0DCyberdollars!', I);
  1550.         GiveMSG (9, '', '^^0FYou^^8D win ^^0F'+ToStr(Round(NodeBet[I]*(3/2)))+' ^^0DCyberdollars!', I);
  1551.         Inc (NodeCD[I], Round(NodeBet[I]*(3/2)));
  1552.         Writeln (NodeUser(I), ' gets a blackjack.');
  1553.       end
  1554.       else
  1555.       If HandValue (NodeHand[I]) > DealerValue then
  1556.       begin
  1557.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D wins ^^0F'+ToStr(NodeBet[I]*NodeDD[I])+' ^^0DCyberdollars!',I);
  1558.         GiveMSG (9, '', '^^0FYou^^8D win ^^0F'+ToStr(NodeBet[I]*NodeDD[I])+' ^^0DCyberdollars!',I);
  1559.         Inc (NodeCD[I], NodeBet[I]*NodeDD[I]);
  1560.       end
  1561.       else
  1562.       If HandValue (NodeHand[I]) < DealerValue then
  1563.       begin
  1564.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D loses ^^0F'+ToStr(NodeBet[I]*NodeDD[I])+' ^^0DCyberdollars!',I);
  1565.         GiveMSG (9, '', '^^0FYou^^8D lose ^^0F'+ToStr(NodeBet[I]*NodeDD[I])+' ^^0DCyberdollars!',I);
  1566.         Dec (NodeCD[I], NodeBet[I]*NodeDD[I]);
  1567.       end
  1568.       else
  1569.       If HandValue (NodeHand[I]) = DealerValue then
  1570.       begin
  1571.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D loses nothing.',I);
  1572.         GiveMSG (9, '', '^^0FYou^^0D lose nothing.',I);
  1573.       end;
  1574.       If NodeInsure[I] then
  1575.       begin
  1576.         Dec (NodeCD[I], Round (NodeBet[I]/2));
  1577.         GiveMSG (9, '', '^^0FYou^^8D lose ^^0Dyour insurance bet of ^^0F'+ToStr(Round(NodeBet[I]/2))
  1578.                  +' ^^0DCyberdollars!', I);
  1579.         If NodeGender (I) then
  1580.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D loses ^^0Dher insurance bet of ^^0F'
  1581.                         +ToStr(Round(NodeBet[I]/2))+' ^^0DCyberdollars!', I)
  1582.         else
  1583.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D loses ^^0Dhis insurance bet of ^^0F'
  1584.                         +ToStr(Round(NodeBet[I]/2))+' ^^0DCyberdollars!', I)
  1585.       end;
  1586.     end;
  1587.     If (NodeHand2[I] <> '') and (HandValue (NodeHand2[I]) < 22) then
  1588.     begin
  1589.       BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D''s second hand: '+ColorHand(NodeHand2[I])+
  1590.                  ' ^^0D(^^0F'+ToStr(HandValue(NodeHand2[I]))+'^^0D)', I);
  1591.       GiveMSG (9, '', '^^0FYour^^0D second hand: '+ColorHand(NodeHand2[I])+
  1592.                  ' ^^0D(^^0F'+ToStr(HandValue(NodeHand2[I]))+'^^0D)', I);
  1593.       If (HandValue (NodeHand2[I]) = 21) and (Length (NodeHand2[I]) = 4) then
  1594.       begin
  1595.         { Blackjack }
  1596.         GiveMSG (9, '', '^^8DYou got a ^^8Fblackjack^^8D!', I);
  1597.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+' ^^0Dhas a ^^0Fblackjack^^0D!', I);
  1598.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D wins ^^0F'+ToStr(Round(NodeBet[I]*(3/2)))
  1599.                           +' ^^0DCyberdollars!', I);
  1600.         GiveMSG (9, '', '^^0FYou^^8D win ^^0F'+ToStr(Round(NodeBet[I]*(3/2)))+' ^^0DCyberdollars!', I);
  1601.         Inc (NodeCD[I], Round(NodeBet[I]*(3/2)));
  1602.         Writeln (NodeUser(I), ' gets a blackjack.');
  1603.       end
  1604.       else
  1605.       If HandValue (NodeHand2[I]) > DealerValue then
  1606.       begin
  1607.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D wins ^^0F'+ToStr(NodeBet[I]*NodeDD2[I])+' ^^0DCyberdollars!',I);
  1608.         GiveMSG (9, '', '^^0FYou^^8D win ^^0F'+ToStr(NodeBet[I]*NodeDD2[I])+' ^^0DCyberdollars!',I);
  1609.         Inc (NodeCD[I], NodeBet[I]*NodeDD2[I]);
  1610.       end
  1611.       else
  1612.       If HandValue (NodeHand2[I]) < DealerValue then
  1613.       begin
  1614.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D loses ^^0F'+ToStr(NodeBet[I]*NodeDD2[I])+' ^^0DCyberdollars!',I);
  1615.         GiveMSG (9, '', '^^0FYou^^8D lose ^^0F'+ToStr(NodeBet[I]*NodeDD2[I])+' ^^0DCyberdollars!',I);
  1616.         Dec (NodeCD[I], NodeBet[I]*NodeDD2[I]);
  1617.       end
  1618.       else
  1619.       If HandValue (NodeHand2[I]) = DealerValue then
  1620.       begin
  1621.         BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^0D loses nothing.',I);
  1622.         GiveMSG (9, '', '^^0FYou^^0D lose nothing.',I);
  1623.       end;
  1624.       If NodeInsure[I] then
  1625.       begin
  1626.         Dec (NodeCD[I], Round (NodeBet[I]/2));
  1627.         GiveMSG (9, '', '^^0FYou^^8D lose ^^0Dyour insurance bet of ^^0F'+ToStr(Round(NodeBet[I]/2))
  1628.                  +' ^^0DCyberdollars!', I);
  1629.         If NodeGender (I) then
  1630.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D loses ^^0Dher insurance bet of ^^0F'
  1631.                         +ToStr(Round(NodeBet[I]/2))+' ^^0DCyberdollars!', I)
  1632.         else
  1633.           BroadCastBut (9, '', '^^0F'+NodeUser(I)+'^^8D loses ^^0Dhis insurance bet of ^^0F'
  1634.                         +ToStr(Round(NodeBet[I]/2))+' ^^0DCyberdollars!', I)
  1635.       end;
  1636.     end;
  1637.   end;
  1638.   GamePlaying := False;
  1639.   SecPassed := 0;
  1640.   For I := 1 to 255 do
  1641.   begin
  1642.     If NodeStat[I] = 2 then NodeStat[I] := 1;
  1643.     NodeDD[I] := 1;
  1644.     NodeDD2[I] := 1;
  1645.     NodeDoneH1[I] := False;
  1646.     NodeDoneH2[I] := False;
  1647.     NodeHand2[I] := '';
  1648.     NodeInsure[I] := False;
  1649.   end;
  1650. end;
  1651.  
  1652. Procedure BootUser;
  1653. begin
  1654.   GiveMSG (9, '', #7'^^8DYou have been thrown out of the ^^8Fblackjack^^8D game for taking too long!', NodeTurn);
  1655.   BroadCastBut (9, '', '^^0DThe ^^0FBlackjack dealer^^0D has thrown ^^0F'+NodeUser(NodeTurn)
  1656.                 +'^^0D out of the game for taking too long!', NodeTurn);
  1657.   NodeStat[NodeTurn] := 0;
  1658.   Dec (NodeCD[NodeTurn], NodeBet[NodeTurn]);
  1659.   WaitSec;
  1660.   NextPlayer;
  1661. end;
  1662.  
  1663. Procedure RunBJ;
  1664. Var
  1665.   ch : Char;
  1666. begin
  1667.   ch := #0;
  1668.   OldSec := 0;
  1669.   SecPassed := 0;
  1670.   GamePlaying := False;
  1671.   Repeat
  1672.     GetTime (L, L, Sec, L);
  1673.     If Sec <> OldSec then
  1674.     begin
  1675.       OldSec := Sec;
  1676.       Inc (SecPassed);
  1677.     end;
  1678.     If not GamePlaying and (SecPassed > ConfigData.TimeBetweenGames) then StartGame;
  1679.     If GamePlaying and (SecPassed = ConfigData.FirstWarn) then WarnUser;
  1680.     If GamePlaying and (SecPassed = ConfigData.SecondWarn) then WarnUser;
  1681.     If GamePlaying and (SecPassed = ConfigData.BootFromBJ) then BootUser;
  1682.     If MSGWait then GetMSGs;
  1683.     Delay (10);
  1684.     If (NodeTurn = -1) and (GamePlaying) then DealerPlay;
  1685.     If Keypressed then ch := Readkey;
  1686.   Until ch = #27;
  1687. end;
  1688.  
  1689. begin
  1690.   InitProgram;
  1691.   InitRAP;
  1692.   InitScreen;
  1693.   InitVars;
  1694.   RunBJ;
  1695.   DeInit;
  1696. end.
  1697.