program Rancho_Nevada;
{$N+,E+,O+,F+}
{$M 32768,65536,655360}
Uses overlay,
     Dos,
     CRT,
     rninit,
     bbskv,
     bbskern,
     nanocore,
     sys_msg,
     engine2,
     rgoods,
     usered,
     robot,
     bldmaze,
     gelin,
     iconfig,
     trade,
     cheri2,
     rkey,
     toyinfo,
     winner,
     miscplay,
     miscpl2,
     miscpl3,
     miscpl4,
     miscpl5,
     encores,
     readonce,
     start_up,
     execswap;

{$O USERED}
{$O ROBOT}
{$O BLDMAZE}
{$O GELIN}
{$O ICONFIG}
{$O TRADE}
{$O CHERI2}
{$O RKEY}
{$O MESSAGE1}
{$O WINNER}
{$O MISCPLAY}
{$O MISCPL2}
{$O MISCPL3}
{$O MISCPL4}
{$O MISCPL5}
{$O ENCORES}
{$O TOYINFO}
{$O READONCE}
{$O START_UP}

function randroom(roomno:word; var direction:string):word;
var tmp2,
    tmp:word;
    t3:string;
begin
  repeat
    tmp2:=random(6);
    case tmp2 of
      0: begin tmp:=room^[roomno].room_north; t3:=g_sysmsg(90); end;
      1: begin tmp:=room^[roomno].room_south; t3:=g_sysmsg(91); end;
      2: begin tmp:=room^[roomno].room_east; t3:=g_sysmsg(92); end;
      3: begin tmp:=room^[roomno].room_west; t3:=g_sysmsg(93); end;
      4: begin tmp:=room^[roomno].room_up;   t3:=g_sysmsg(94); end;
      5: begin tmp:=room^[roomno].room_down; t3:=g_sysmsg(95); end;
    end
  until tmp<>0;
  direction:=t3;
  randroom:=tmp;
end;

function sameday(L1,L2:longint):boolean;
var tmp:boolean;
    k1,k2:longint;
begin
  k1:=L1 div 86400; k2:=L2 div 86400;
  tmp:=(k1=k2);
  sameday:=tmp;
end;

function u_in_rm(n:namestr):boolean;
var index:byte;
    t:boolean;
begin
  n:=upcasestr(n);
  t:=false;
  for index:=1 to maxuser do
  if
    (upcasestr(userlog^[index].name)=n)
  and
    (userlog^[index].room=user.room)
  then
    t:=true;
  u_in_rm:=t;

end;

procedure encounter;
var
    amt:longint;
    tch:char;
    surprise,done:boolean;
    minushp:longint;
    action:integer;
    tmpxp:comp;
    playerwon:boolean;
    diff:integer;
    etmp:extended;
label _luckprompt;
begin
  disease:=false; playerwon:=true; invkr:=false;
  spellpriv[13]:=false; spellpriv[14]:=false; spellpriv[15]:=false; spellpriv[16]:=false;
  if
    user.hp<1
  then
    begin
      sysmsg(100); {Your libido is dried up - no more passes}
      exit;
    end;
  repeat
    begin
_luckprompt:
      parameter[1]:=int2str(maxuser);
      sysmsg(101); {Who will you get lucky with?}
      tstr:=getln(35);
      tstr:=upcasestr(tstr);
      if (tstr='') or (tstr='Q') or (tstr='X') then exit;
      if (tstr='H') or (tstr='?') then begin sendln('`K'); userlist(false); sendln(''); goto _luckprompt; end;
      amt:=lookupuser(tstr);
      if
        (amt<=0) or (amt>maxuser)
      then
        sysmsg(102)
      else
        if
          amt>0
        then
          begin
            user2:=userlog^[amt];
            user2.hp:=user2.maxhp;

            if {User specified himself}
              upcasestr(user.name)=upcasestr(user2.name)
            then
              begin
                sysmsg(103);
                exit;
              end;

            if
              user.level>user2.level
            then
              begin
                diff:=user.level-user2.level;
                if
                  diff>config.maxdiff
                then
                  begin
                    parameter[1]:=user2.name; sysmsg(104);
                    exit;
                  end;
              end;

            if  {Gay attempt made BY straight player}
              (user.gender=user2.gender)
            and
              (user.orientation=straight)
            then
              begin
                parameter[1]:=getgen(user.gender,5);
                parameter[2]:=user2.name;
                parameter[3]:=getgen(user2.gender,5);
                sysmsg(105);
                exit;
              end;

            if  {Straight attempt made BY gay player}
              (user.gender<>user2.gender)
            and
              (user.orientation=gay)
            then
              begin
                parameter[1]:=user2.name;
                parameter[2]:=getgen(user2.gender,5);
                case user.gender of
                  female: parameter[3]:=g_sysmsg(107);
                  male: parameter[3]:=g_sysmsg(108);
                end;
                sysmsg(106);
                exit;
              end;

            if  {Gay attempt made on straight player}
              (user.gender=user2.gender)
            and
              (user2.orientation=straight)
            then
              begin
                parameter[1]:=user2.name;
                parameter[2]:=getgen(user2.gender,5);
                sysmsg(109);
                exit;
              end;

            if  {Straight attempt made on gay player}
              (user.gender<>user2.gender)
            and
              (user2.orientation=gay)
            then
              begin
                parameter[1]:=user2.name;
                case user2.gender of
                  female: parameter[2]:=g_sysmsg(107);
                  male: parameter[2]:=g_sysmsg(108);
                end;
                sysmsg(110);
                exit;
              end;

            if
              not(u_in_rm(user2.name))
            then
              begin
                parameter[1]:=getgen(user2.gender,6);
                sysmsg(111);
                exit;
              end;
            if
              user2.recovering
            then
              begin
                parameter[1]:=mixedcase(getgen(user2.gender,2));
                sysmsg(112);
                exit;
              end;
            parameter[1]:=user.name;
            parameter[2]:=user2.name;
            sysmsg(113);

{ Here is where we decide if this is an online or regular encounter }

            checkwhoson;
            if uon[amt].online then online_attack(amt,playerwon) else encore(playerwon);

            sendln('');
            if not(abortedfuck) then donefuck(playerwon);

            WriteUser(user2.name,user2);
            writeuser(user.name,user);
            exit;
          end;
    end;
  until quitnow or lostcarrier;
end;

procedure vkr;
var tstr:string[3];
    done:boolean;
    x:byte;
    playerwon:boolean;
    ltmp:longint;
    ltmp2:longint;
    rtmp:real;
    tch:char;
    hiroom:word;
    brand:byte;
    gs1,gs2:string[10];
label _mvirg;
label _exit;
begin
  nuke('USER-'+int2str(thisusernumber)+'.VKR');
  whoosh:=false;
  if
    beeninvkr
  then
    begin
      sysmsg(114);
      exit;
    end;
  if
    config.vkrkey
  then
    if
      not(hasvkrkey)
    then
      begin
        sysmsg(1102);
        exit;
      end;
  hasvkrkey:=false;
  timesjacuzzi:=0;
  getoutvkr:=false;
  spellpriv[5]:=false;
  spellpriv[11]:=false;
  spellpriv[12]:=true;
  spellpriv[13]:=false;
  spellpriv[14]:=false;
  spellpriv[15]:=false;
  spellpriv[16]:=false;
  invkr:=true;
  location:=1;
  done:=false;
  playerwon:=true;
  location:=1;
  if quitnow or getoutvkr then exit;
  if config.vkrkey then sysmsg(1103);
  makesem('USER-'+int2str(thisusernumber)+'.VKR');
  beeninvkr:=true; hasvkrkey:=false;
  repeat
    (******** This Block of Code Generates The Virgin ********)
_mvirg:
    default(user2);
    if
      user.orientation=bi
    then
      begin
        x:=random(10);
        if x<5 then user2.gender:=male else user2.gender:=female;
      end
    else
      if user.gender=female then user2.gender:=male;
    user2.name:=synthname(user2.gender);
    if location=20 then
      begin
        if (user.gender=male) and (user2.gender=male) then user2.name:='Queen Marvin of Vegas';
        if (user.gender=female) and (user2.gender=female) then user2.name:='Queen Dominatrix Ilka';
        if (user.gender=male) and (user2.gender=female) then user2.name:='Miss Nude Universe';
        if (user.gender=female) and (user2.gender=male) then user2.name:='John Holmes, Jr.';
      end;
    user2.level:=location*5;
    user2.xp:=nextlevelxp(user2.level-1);
    user2.robot:=true; user2.recovering:=false;
    ltmp2:=user2.level*user2.level; ltmp2:=ltmp2*user2.level; ltmp2:=ltmp2 div 8;
    ltmp:=user2.level*10; ltmp:=ltmp*user2.level; ltmp:=ltmp+ltmp2;
    user2.maxhp:=ltmp;
    user2.hp:=user2.maxhp;
    if location=20 then user2.hp:=longint(user.maxhp*10);
    user2.weapon:=user2.level*2+random(4);
    user2.armor:=((user2.level*3) shr 1)+random(3);
    user2.skill:=((user2.level-1) shl 4)+10;
    user2.stamina:=user2.skill;
    ltmp:=user2.maxhp;
    ltmp:=ltmp*10;
    ltmp2:=bigrnd(user2.maxhp);
    ltmp2:=ltmp2*4;
    ltmp:=ltmp+ltmp2;
    user2.gp:=ltmp;
    user2.gp:=raisepower(user2.level,3.2)*60+100;
    rtmp:=random*0.5;
    user2.gp:=user2.gp+(user2.gp*rtmp);
    if
      location=20
    then
      begin
        user2.weapon:=user.weapon+1;
        user2.armor:=user.armor+1;
        user2.stamina:=user.stamina;
        user2.skill:=user.skill;
      end;
    (********* End of Enemy-Making Block *************)
    tch:=' ';
    if
      location<>1
    then
      repeat
        whoosh:=false;
        if quitnow then goto _exit;
        sendln('');
        spellpriv[5]:=true;
        if
          config.vkrmove
        then
          begin
            if (movesleft>0) then dec(movesleft);
            parameter[1]:=int2str(movesleft); sysmsg(116);
          end;
        spellpriv[12]:=true;
        sysmsg(117);
        checkemail;
        get('qmuy'+chr(13));
        tch:=upcase(ctmp);
        if
          tch='Y'
        then
          begin
            sysmsg(118);
            yourstats;
          end;
        if
          tch='Q'
        then
          begin
            getoutvkr:=true;
            sysmsg(1140);
            goto _exit;
          end;
        if
          tch='U'
        then
          begin
            sysmsg(119);
            usespecial;
            if quitnow or getoutvkr then goto _exit;
          end;
      until (tch=chr(13)) or (tch='M') or quitnow or lostcarrier or whoosh;
    spellpriv[5]:=false;
    if quitnow or getoutvkr then goto _exit;
    if whoosh then if location>20
    then
      begin
        sysmsg(1106);
        goto _exit;
      end;
    if whoosh then goto _mvirg;
    if not whoosh then sysmsg(120);
    whoosh:=false;
    parameter[1]:=int2str(location); sysmsg(121);
    brand:=random(2); { random 0 or 1, if 1 then player defends }
    if location=20 then brand:=0; {For big kah0na it's always attack}

    if
      location=20
    then
      begin
        gs1:=getgen(user2.gender,1); gs2:=getgen(user2.gender,2);
        totallines:=0;
        parameter[1]:=user2.name;
        sysmsg(1141);
        yndefault:=true; tch:=upcase(yn);
        if (tch='N') then goto _exit;
      end;

    parameter[1]:=user2.name; parameter[2]:=int2str(user2.level);
    if brand=0 then sysmsg(122) else sysmsg(123);

    abortedfuck:=false;
    if brand=0 then encore(playerwon) else encore2(playerwon);
    invkr:=true;
    if brand=0 then if not abortedfuck then donefuck(playerwon);
    if not(brand=0) then if not abortedfuck then donefuck2(playerwon);
    done:=not(playerwon);
    if (playerwon) and (location=20) then begin youwin; goto _exit; end;
    if getoutvkr then goto _exit;
    if
      (location=config.specialtoy)
    then
      begin
        parameter[1]:=int2str(location);
        sysmsg(124);
        user.weapon:=9999;
        writeuser(username,user);
      end;
    if
      (location=config.specialdefense)
    then
      begin
        parameter[1]:=int2str(location);
        sysmsg(125);
        user.armor:=9999;
        writeuser(username,user);
      end;
        if
          (config.vkrmove and (movesleft<=0))
        then
          begin
            sysmsg(1080);
            goto _exit;
          end;
    inc(location);
    if
      location>20
    then
      begin
        done:=true;
      end;
  until done or quitnow or lostcarrier;
_exit:
  nuke('USER-'+int2str(thisusernumber)+'.VKR');
end;



(**** PROCEDURE ENTERMAZE --- This is the real main loop of Rancho. ****)

procedure entermaze(startroom:word);
var attacked:boolean;
    kkk:integer;
    iti:integer;
label _mainprompt;

{} procedure cantgo;
{} begin
{}   sysmsg(127);
{} end;
{}
{} procedure dspecial(special:word);
{} begin
{}   case special of
{}     1: if
{}          not(config.novkr)
{}        then
{}          sysmsg(128);
{}     2: sysmsg(129);
{}     3: sysmsg(130);
{}     4: sysmsg(131);
{}     5: sysmsg(132);
{}     6: sysmsg(133);
{}     7: sysmsg(134);
{}     8: sysmsg(135);
{}     9: sysmsg(882);
{}    10: sysmsg(1110);
{}    11: sysmsg(1113);
{}    12: sysmsg(1127);
{}    13: sysmsg(1131);
{}   end; {case}
{} end;
{}
{} procedure uspecial(special:word);
{} begin
{}   updatewhoson;
{}   case special of
{}     1: if not(config.novkr) then begin sysmsg(136); vkr; end;
{}     2: begin sysmsg(137); sexshoppe; end;
{}     3: begin sysmsg(138); drinking; end;
{}     4: begin sysmsg(139); payphone; end;
{}     5: begin sysmsg(140); terminal; end;
{}     6: begin sysmsg(141); avterm; end;
{}     7: begin sysmsg(142); bank; end;
{}     8: begin sysmsg(143); jacuzzi; end;
{}     9: begin sysmsg(860); slots; end;
{}    10: begin sysmsg(1111); do_safe; end;
{}    11: begin sysmsg(1112); rgoods.usingmachine:=true; buycondoms; end;
{}    12: masseuse;
{}    13: begin sysmsg(1132); shower; end;
{}   else
{}     sysmsg(144);
{}   end;
{} end;
{}
{} procedure dpeople(thisroom:word);
{} var index:word;
{}     gotit:boolean;
{}     hits:word;
{}     t3,tstr,tstr2:string;
{} begin
     checkuserfile;
     scatter;
{}   gotit:=false; tstr:=''; tstr2:='';
{}   index:=0; hits:=0;
{}   sendln(''); abort:=false;
{}   repeat
{}   begin
{}     inc(index);
{}     if
{}       (userlog^[index].room=thisroom)
{}     and
{}       not(index=thisusernumber)
{}     and
{}       not(userlog^[index].deleted)
{}     then
{}       begin
{}         parameter[1]:=int2str(index);
{}         parameter[2]:=mixedcase(userlog^[index].name);
{}         t3:=g_sysmsg(145);
{}         tstr2:=tstr+t3;
{}         if
{}           tstr2[0]>#85
{}         then
{}           begin
{}             sendln(tstr);
{}             tstr:=t3;
{}           end
{}         else
{}           tstr:=tstr+t3;
{}         gotit:=true;
{}       end;
{}   end;
{}   until (index>=maxuser) or (abort) or quitnow or lostcarrier;
{}   if gotit then sendln(tstr);
{}   if
{}     not(gotit)
{}   then
{}     sysmsg(146);
{} end;
{}
{} procedure runaway(thisroom:word);
{} var index:word;
{}     playerwon,
{}     gotit:boolean;
{}     hits:word;
{}     strength,strength2:comp;
{}     tmp:byte;
{}     direction:string;
{}     newroom:word;
{} begin
{}   playerwon:=true;
{}   strength:=user.skill*user.stamina*user.maxhp;
{}   gotit:=false;
{}   index:=0; hits:=0;
{}   for index:=1 to maxuser do
{}   begin
{}     if
{}       (userlog^[index].room=thisroom)
{}     and
{}       (not(index=thisusernumber))
       and
         (not(uon[index].online))
       and
        (not(userlog^[index].deleted))
{}     and
{}     {  (not((userlog^[index].attackmode=0) or hasattacked[index])) } (not hasattacked[index])
{}     then
{}       begin
(*{}         reset(uf);
{}         seek(uf,index-1);
{}         read(uf,user2);
{}         close(uf); *)
           user2:=userlog^[index];
{}         strength2:=user2.skill*user2.stamina*user2.maxhp;
{}         if
{}           (userlog^[index].attackmode=1) {Paranoid}
{}         or
{}           ((userlog^[index].attackmode=2) and (strength2<strength)) {Coward - weak case}
{}         or
{}           ((userlog^[index].attackmode=3) and (strength2<strength)) {Chicken}
           or
            ((random(5)=4) and (strength>strength2*3)) {1 in 5 chance that much weaker players will run}
           or
             (random(9)=8) {1 in 9 chance that anyone will run regardless}
{}         then
{}           begin
{}             tmp:=random(100);
{}             if
{}               tmp<config.corner
{}             then
{}               begin
{}                 parameter[1]:=mixedcase(user2.name);
{}                 parameter[2]:=getgen(user2.gender,3);
{}                 sysmsg(147);
{}               end
{}             else
{}               begin
{}                 newroom:=randroom(user.room,direction);
{}                 parameter[1]:=mixedcase(user2.name);
{}                 parameter[2]:=direction;
{}                 sysmsg(148);
{}                 user2.room:=newroom;
{}                 userlog^[index].room:=newroom;
{}                 WriteUser(user2.name,user2);
{}               end;
{}           end;
{}       end;
{}   end;
{} end;
{}
{} procedure attack(thisroom:word);
{} var index:word;
{}     playerwon,
{}     gotit:boolean;
{}     hits:word;
{}     strength,strength2:comp;
{}     tmp:byte;
{}     direction:string;
{}     newroom:word;
{}     diff:longint;
{} begin
{}   if quitnow then exit;
{}   playerwon:=true;
{}   strength:=user.skill*user.stamina*user.maxhp;
{}   gotit:=false;
{}   index:=0; hits:=0;
{}   for index:=1 to maxuser do
{}   begin
{}     if
{}       (userlog^[index].room=thisroom)
{}     and
{}       (not(index=thisusernumber))
       and
        (not(userlog^[index].deleted))
{}     and
{}  {     (not((userlog^[index].attackmode=0) or attacked[index])) } (not hasattacked[index])
{}     then
{}       begin
(*{}         reset(uf);
{}         seek(uf,index-1);
{}         read(uf,user2);
{}         close(uf); *)
           user2:=userlog^[index];
{}         strength2:=user2.skill*user2.stamina*user2.maxhp;
         if
           (not(uon[index].online))
         then
{}         if
{}           (userlog^[index].attackmode=6)  {Berserk}
{}         or
{}           ((userlog^[index].attackmode=5) and (strength>strength2)) {Suicide}
{}         or
{}           ((userlog^[index].attackmode=4) and (strength<strength2)) {Normal}
{}         or
{}           ((userlog^[index].attackmode=2) and (strength<strength2)) {Coward - attack case}
           or
             (random(200)=1) {1 in 200 chance that anyone will attack}
{}         then
{}           begin
{}             diff:=user2.level-user.level;
{}             attacked:=true;
{}             hasattacked[index]:=true;
{}             if
{}               (diff>0)
{}             or
{}               ((room^[thisroom].attr and $80)<>0)
{}             then
{}               begin
{}                 parameter[1]:=mixedcase(user2.name);
{}                 sysmsg(149);
{}                 exit;
{}               end;
{}             parameter[1]:=mixedcase(user2.name);
{}             sysmsg(150);
{}             abortedfuck:=false;
{}             user2.hp:=user2.maxhp;
{}             encore2(playerwon);
{}             if not abortedfuck then donefuck2(playerwon);
{}             WriteUser(user2.name,user2);
{}             writeuser(user.name,user);
{}           end;
{}       end;
{}   end;
{} end;

begin
  attacked:=false;
  user.room:=startroom;
  hasvkrkey:=false;
  repeat
    if user.gp<0 then user.gp:=0;
    if user.bankgp<0 then user.bankgp:=0;
    begin
      with room^[user.room] do
        begin
          sendln('`B');
          if quitnow then exit;
          totallines:=0;
          sysmsg(151);
          if
            (user.room=0) or not(goodroom(user.room))
          then
            begin
              sysmsg(152);
              user.room:=1;
            end;
          parameter[1]:=description; parameter[2]:=int2str(user.room);
          sysmsg(153);
          if (attr and $80)<>0 then sysmsg(154); {no sex}
          checkuserfile; checkwhoson;

          if
            (not(hasvkrkey)) and (config.vkrkey)
          then
            for iti:=1 to 4 do
              if
                (user.room=keyloc[iti])
              then
                begin
                  sysmsg(1105);
                  keyloc[iti]:=0;
                  hasvkrkey:=true;
                  anykey;
                end;

          if
            (attr and $20)<>0 {too dark}
          then
            sysmsg(155)
          else
            begin
              dspecial(special);
              dpeople(user.room);
            end;
          runaway(user.room);
          sysmsg(156);
          if room_east>0  then sysmsg(84); {`NEast}
          if room_west>0  then sysmsg(85); {`OWest}
          if room_north>0 then sysmsg(86); {`KNorth}
          if room_south>0 then sysmsg(87); {`JSouth}
          if room_up>0    then sysmsg(88); {`LUp}
          if room_down>0  then sysmsg(89); {`MDown}
          awardxp(user,0);
          spellpriv[1]:=true;  spellpriv[2]:=false; spellpriv[3]:=false;
          spellpriv[4]:=false; spellpriv[5]:=false; spellpriv[6]:=false;
          spellpriv[7]:=false; spellpriv[8]:=false; spellpriv[9]:=false;
          spellpriv[10]:=false; spellpriv[11]:=true; spellpriv[12]:=false;
          spellpriv[13]:=true; spellpriv[14]:=true; spellpriv[15]:=true;
          spellpriv[16]:=true;
          yndefault:=yes;

_mainprompt:

          if config.vkrkey then if hasvkrkey then sysmsg(1104);
          parameter[1]:=int2str(movesleft);
          parameter[2]:=getgen(user.gender,7);
          parameter[3]:=mixedcase(user.name);
          sysmsg(157);

          invkr:=false;
          updatesbar;
          attack(user.room);
          {Emergency checks!}
          if user.gp<0 then user.gp:=0;
          if user.xp<100 then user.xp:=100;
          if user.maxhp<1 then user.maxhp:=1;
          if user.bankgp<0 then user.bankgp:=0;
          {End of emergency checks}
          ctmp:=' ';
          if (newtothisroom and (random(20)=0)) then begin randomgoodies; goto _mainprompt; end;
          if
            not(attacked)
          then  {a_cdef_hi__lmnopqrstuvwy?$}
            get('nsewudhimyrtqlop?$vaxcf12345'#7#13#25#1#2);
            if (ds1970>datein) then begin user.playstoday:=0; movesleft:=config.maxmoves; datein:=ds1970; end;
            if ctmp=#00 then if not quitnow then goto _mainprompt;
            if quitnow then exit;
            begin
              attacked:=false;
              tch:=upcase(ctmp);
              changecolour('L');
              case tch of
                #1: begin r_sextoy; end;
                #2: begin r_defense; end;
                chr(13): nothing;
                chr(25): begin
                           ctmp:=echochar;
                           echochar:='';
                           stmp:=getln(8);
                           echochar:=ctmp;
                           stmp:=upcasestr(stmp);
                           if stmp=imzadi then
                             begin
                               spymode:=true;
                               config.minushp:=config.minushp*4;
                             end;
                         end;
                '1' : sendtext('COLORS.TXT');
                '2' : sendln(crlf+crlf+'`JThis is not `PL.O.R.D.`J - we don''t have cheat keys.  Hacking is futile.');
                '3' : sendln(crlf+crlf+'`CYou are not `KZero Cool.`C  Give it up.');
                '4' : sendln(crlf+crlf+'`GOK, you think you''re a hacker, try hacking this: `OTHC BBS (250) 361-4549');
                '5' : sendln(crlf+crlf+'`FSurprise!  You win...   `NABSOLUTELY NOTHING!!!');
                #7  : begin sendln(crlf+crlf+'`JBeep yourself, creep!'); for kkk:=1 to 15 do com_tx(#7); end;
                '$' : banner;
                'A' : begin sayit; goto _mainprompt; end;
                'C' : begin
                        sysmsg(799);
                        if
                          user.spell[13]<>0
                        then
                          payphone
                        else
                          sysmsg(798);
                      end;
                'O' : begin sysmsg(159); lookroom; end;
                'I' : begin sysmsg(160); usespecial; end;
                'Y' : begin sysmsg(161); yourstats; end;
                'R' : begin sysmsg(162); rankings; end;
                'L' : begin sysmsg(163); userlist(false); end;
                'P' : begin sendln(crlf); listwhoson; sendln(crlf); end;
                'X' : begin
                        sendln(crlf);
                        viewdescription(user.room);
                        if newtothisroom then if (random(3)=0) then randomgoodies;
                      end;
                'Q' : begin
                        yndefault:=no;
                        sysmsg(164);
                        ctmp:=yn; ctmp:=upcase(ctmp);
                        if ctmp='Y' then begin sendln(''); quitnow:=true; end;
                        yndefault:=yes;
                      end;
                'H' : sendtext('INSTRUCT.ASC');
                'F' : begin sysmsg(165); sendtext('RANCHO.LOG'); sendln('`,'); anykey; end;
                '?' : begin
                        if
                          false
                        then
                          begin
                            sendln('');
                            sendtext('MAINHELP.RIP');
                          end
                        else
                          begin
                            sysmsg(166);
                            if
                              ansi
                            then
                              sendtext('MAINHELP.ANS')
                            else
                              sendtext('MAINHELP.ASC');
                         end;
                        if not rip then anykey;
                      end;
                'M' : begin
                        sysmsg(167);
                        if
                          (attr and $80)<>0
                        then
                          begin
                            sysmsg(168);
                          end
                        else
                          encounter;
                      end;
                'T' : begin sysmsg(169); tradestats; end;
                'V' : if
                        special in [1..13]
                      then
                        uspecial(special)
                      else
                        sysmsg(742);
                'N' : begin
                        sysmsg(90); sendln('');
                        if
                          (room_north>0) and (movesleft>0)
                        then
                          begin
                            saywent(90);
                            user.room:=room_north;
                            if (attr and $40)=0 then dec(movesleft);
                            updatewhoson;
                            saycame;
                            newtothisroom:=true;
                          end
                        else
                          cantgo;
                      end;
                'S' : begin
                        sysmsg(91); sendln('');
                        if
                          (room_south>0) and (movesleft>0)
                        then
                          begin
                            saywent(91);
                            user.room:=room_south;
                            if (attr and $40)=0 then dec(movesleft);
                            updatewhoson;
                            saycame;
                            newtothisroom:=true;
                          end
                        else
                          cantgo;
                      end;
                'E' : begin
                        sysmsg(92); sendln('');
                        if
                          (room_east>0) and (movesleft>0)
                        then
                          begin
                            saywent(92);
                            user.room:=room_east;
                            if (attr and $40)=0 then dec(movesleft);
                            updatewhoson;
                            saycame;
                            newtothisroom:=true;
                          end
                        else
                          cantgo;
                      end;
                'W' : begin
                        sysmsg(93); sendln('');
                        if
                          (room_west>0) and (movesleft>0)
                        then
                          begin
                            saywent(93);
                            user.room:=room_west;
                            if (attr and $40)=0 then dec(movesleft);
                            updatewhoson;
                            saycame;
                            newtothisroom:=true;
                          end
                        else
                          cantgo;
                      end;
                'U' : begin
                        sysmsg(94); sendln('');
                        if
                         ( room_up>0) and (movesleft>0)
                        then
                          begin
                            saywent(94);
                            user.room:=room_up;
                            if (attr and $40)=0 then dec(movesleft);
                            updatewhoson;
                            saycame;
                            newtothisroom:=true;
                          end
                        else
                          cantgo;
                      end;
                'D' : begin
                        sysmsg(95); sendln('');
                        if
                          (room_down>0) and (movesleft>0)
                        then
                          begin
                            saywent(95);
                            user.room:=room_down;
                            if (attr and $40)=0 then dec(movesleft);
                            updatewhoson;
                            saycame;
                            newtothisroom:=true;
                          end
                        else
                          cantgo;
                      end;
              else
                begin
                end;
              end;  {case}
          end; {if attacked}
        end;    {with..do}
    end;        {repeat}
  until quitnow or lostcarrier;
end;            {procedure entermaze}

Begin {Main Program}
  exitsave:=exitproc;
  exitproc:=@killstat;
  startup;
  editmode:=false; youwon:=false;

{***********************    Main Loop    **********************************}
  if lostcarrier then nocarrier;
  pregame:=true;
  makestat; updatewhoson;
  if
    (user.playstoday<config.maxplays) or (user.givenvd)
  then
    begin
      updatesbar;
      user.recovering:=false;
      send('`2');
      if not exist('RANCHO.LOG') then startlog;
      sendtext('RANCHO.LOG'); sendln(''); anykey;
      sendln(''); listwhoson;
      verbbump:=true;
      sysmsg(10);
      readmsgs;
      checkevents(user.name);
      changecolour('P');
      awardxp(user,0);
      parameter[1]:=int2str(user.jws);
      parameter[2]:=int2str(user.jls);
      sysmsg(11);
      user.jls:=0; user.jws:=0;
      purgeevent(user.name);
      if
        user.givenvd
      then
        begin
          sysmsg(12);
          handlevd;
          btmp:=quitnow; quitnow:=false;
          anykey;
          quitnow:=btmp;
        end;
      updatesbar;
      if user.room=0 then user.room:=1;
      pregame:=false;
      {These parameters apply to both msgs 755 and 754}
      parameter[1]:=user.name;
      parameter[2]:=getgen(user.gender,2);
      parameter[3]:=getgen(user.gender,1);
      global_oneannounce(g_sysmsg(755));
      oneannounce(g_sysmsg(754));
      if not registree then config.winlevel:=100;
      entermaze(user.room);
      {These parameters apply to both 756 and 753}
      parameter[1]:=user.name;
      parameter[2]:=getgen(user.gender,2);
      parameter[3]:=getgen(user.gender,1);
      oneannounce(g_sysmsg(753));
      global_oneannounce(g_sysmsg(756));
      inc(user.playstotal);
      if
        user.playstoday<65535
      then
        begin
          inc(user.playstoday);
          user.lastplayed:=ds1970;
          writeuser(user.name,user);
          parameter[1]:=int2str(config.maxplays-user.playstoday);
          parameter[2]:=int2str(config.maxplays);
          parameter[3]:=int2str(user.playstoday);
          sysmsg(13);
        end;
    end
  else
    begin
      if
        user.playstoday=65535
      then
        begin
          sysmsg(14); sendln('');
          anykey;
          quitnow:=true;
        end
      else
        begin
          parameter[1]:=int2str(config.maxplays);
          sysmsg(15); sendln('');
          anykey;
          quitnow:=true;
        end;
    end;
{***********************  End Main Loop  **********************************}

  btmp:=quitnow; quitnow:=false;
  sysmsg(16);
  rank10:=true; rankings; rank10:=false;
  if not btmp then registree:=checkkey;
  totallines:=1;
  if
    registree
  then
    sendln(crlf+'`HExiting to `J'+key.bbsname)
  else
    begin
      sendln(crlf+'`JIf you enjoy playing this game, please ask your sysop to register it!');
      sendln('It is not possible to win Rancho Nevada until it has been registered!'+crlf);
      sendln('`Bp.s. perhaps you might consider "adopting" this door for your sysop...');
      sendln('');
      sendln('`GThe author can be contacted at:');
      sendln('`GTHC BBS : `O250-361-4549  `M35,000 Text Files Online');
      sendln('`GInternet: `Ofixer@bc1.com');
      sendln(crlf+'`HExiting to BBS...');
    end;
  shutdown;
end.
