
unit trade;
{$O+,F+}
{$E+,N+}
interface

procedure tradestats;

implementation

uses dos,crt,bbskv,bbskern,engine2,rgoods,usered,sys_msg;


procedure tradestats;
var tch,tch2,tch3:char;
    give,take,maxtake:longint;
    tstr:string;
    temp1,temp2:namestr;
    tempc:word;
    got,got2:boolean;
    cost:longint;
    c1,c2:byte;
    t1,t2:word;
begin
  repeat
    sysmsg(547);
    yndefault:=yes;
    sysmsg(548);
    get('12345678q'#13);
    changecolour('L');
    tch:=upcase(ctmp);
    case tch of
      #13,
      'Q' : begin
              sysmsg(549);
              writeuser(user.name,user);
              exit;
            end;
      '8' : begin
              sysmsg(715);
              tstr:=getln(35);
              if tstr='' then exit;
              parameter[1]:=tstr;
              sysmsg(716);
              tch:=upcase(yn);
              if
                (tch='Y')
              then
                begin
                  user.name:=tstr;
                  userlog^[thisusernumber]:=user;
                  writeuserlog;
                end
              else
                begin
                  exit;
                end;
            end;
      '7' : begin
              parameter[1]:=int2str(user.maxhp);
              parameter[2]:=int2str(user.maxcoord);
              sysmsg(550);
              get('12q'#13);
              tch2:=upcase(ctmp);
              case tch2 of
                #13,
                'Q': sysmsg(551);
                '1': begin
                       sysmsg(552);
                       t1:=user.maxhp;
                       if
                         t1<=10
                       then
                         sysmsg(553)
                       else
                         begin
                           parameter[1]:=int2str(t1-10);
                           sysmsg(554);
                           tstr:=getln(9);
                           tempc:=str2int(tstr);
                           ltmp:=tempc; ltmp:=ltmp*9; ltmp:=ltmp div 10;
                           sendln('');
                           if
                             (ltmp>(t1-10))
                           then
                             sysmsg(555)
                           else
                             begin
                               parameter[1]:=int2str(ltmp);
                               sysmsg(556);
                               ctmp:=yn; ctmp:=upcase(ctmp);
                               if
                                 ctmp='Y'
                               then
                                 begin
                                   user.maxhp:=user.maxhp-tempc; user.hp:=user.maxhp;
                                   user.maxcoord:=user.maxcoord+ltmp; user.coord:=user.maxcoord;
                                   parameter[1]:=int2str(user.maxhp);
                                   parameter[2]:=int2str(user.maxcoord);
                                   sysmsg(557);
                                 end;
                             end;
                         end;
                     end;
                '2': begin
                       sysmsg(558);
                       t1:=user.maxcoord;
                       if
                         t1<=10
                       then
                         sysmsg(559)
                       else
                         begin
                           parameter[1]:=int2str(t1-10);
                           sysmsg(560);
                           tstr:=getln(9);
                           tempc:=str2int(tstr);
                           ltmp:=tempc; ltmp:=ltmp*9; ltmp:=ltmp div 10;
                           sendln('');
                           if
                             (ltmp>(t1-10))
                           then
                             sysmsg(555)
                           else
                             begin
                               parameter[1]:=int2str(ltmp);
                               sysmsg(561);
                               ctmp:=yn; ctmp:=upcase(ctmp);
                               if
                                 ctmp='Y'
                               then
                                 begin
                                   user.maxcoord:=user.maxcoord-tempc; user.coord:=user.maxcoord;
                                   user.maxhp:=user.maxhp+ltmp; user.hp:=user.maxhp;
                                   parameter[1]:=int2str(user.maxhp);
                                   parameter[2]:=int2str(user.maxcoord);
                                   sysmsg(557);
                                 end;
                             end;
                         end;
                     end;
              end; {Case Tch2}
            end; {case of 7}
      '1' : begin
              cost:=user.level*user.level;
              cost:=cost*1000;
              parameter[1]:=int2str(cost);
              sysmsg(562);
              if
                cost>user.gp
              then
                sysmsg(563)
              else
                begin
                  sysmsg(564);
                  tch3:=yn; tch3:=upcase(tch3);
                  if
                    tch3='Y'
                  then
                    begin
                      user.gp:=user.gp-cost;
                      if
                        user.gender=female
                      then
                        user.gender:=male
                      else
                        user.gender:=female;

                      parameter[1]:=mixedcase(user.name);
                      parameter[2]:=getgen(user.gender,5);
                      log(g_sysmsg(565));
                      sysmsg(566);
                    end;
                end;
            end;
      '2' : begin
              cost:=user.level*user.level;
              cost:=cost*1200;
              parameter[1]:=int2str(cost);
              sysmsg(567);
              if
                cost>user.gp
              then
                sysmsg(568)
              else
                begin
                  sysmsg(569);
                  tch3:=yn; tch3:=upcase(tch3);
                  if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                  if
                    tch3='Y'
                  then
                    begin
                      user.gp:=user.gp-cost;
                      got:=false;
                      repeat
                          if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                          sysmsg(570);
                          get('sbgf?');
                          if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                          case upcase(ctmp) of
                            'S' : begin
                                    sysmsg(571);
                                    if
                                      user.orientation=straight
                                    then
                                      sysmsg(572)
                                    else
                                      begin
                                        user.orientation:=straight;
                                        got:=true;
                                      end;
                                  end;
                            'B' : begin
                                    sysmsg(573);
                                    if
                                      user.orientation=bi
                                    then
                                      sysmsg(574)
                                    else
                                      begin
                                        user.orientation:=bi;
                                        got:=true;
                                      end;
                                  end;
                            'G' : begin
                                    sysmsg(575);
                                    if
                                      user.orientation=gay
                                    then
                                      sysmsg(576)
                                    else
                                      begin
                                        user.orientation:=gay;
                                        got:=true;
                                      end;
                                  end;
                            '?' : if ansi then sendtext('birdbee2.ans') else sendtext('birdbee2.asc');
                          end;
                      until got or quitnow or lostcarrier;
                      if lostcarrier then begin nocarrier; quitnow:=true; exit; end;

                      case user.orientation of
                        straight: parameter[1]:=g_sysmsg(577);
                        gay: parameter[1]:=g_sysmsg(578);
                        bi: parameter[1]:=g_sysmsg(579);
                      end;
                      sysmsg(580);

                      parameter[2]:=user.name;
                      {parameter 1 carried from 580}
                      log(g_sysmsg(581));
                    end;
                end;
            end;
      '3' : begin
              sysmsg(582);
              got2:=false;
              repeat
                parameter[1]:=int2str(user.stamina);
                parameter[2]:=int2str(user.skill);
                parameter[3]:=int2str(user.knowledge);
                parameter[4]:=int2str(user.talent);
                sysmsg(583);
                if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                get('1234'#13);
                if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                tch3:=ctmp;
                if tch3=#13 then begin sysmsg(584); exit; end;
                tstr[0]:=#1; tstr[1]:=tch3; c1:=str2int(tstr);
                if
                  (c1>4)
                or
                  (c1<1)
                then
                  sysmsg(585)
                else
                  got:=true;
              until got or lostcarrier or quitnow;
              if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
              sendln(tstr);
              got:=false;
              repeat
                if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                sendln('');
                parameter[1]:=int2str(user.stamina);
                parameter[2]:=int2str(user.skill);
                parameter[3]:=int2str(user.knowledge);
                parameter[4]:=int2str(user.talent);
                if c1<>1 then sysmsg(587);
                if c1<>2 then sysmsg(588);
                if c1<>3 then sysmsg(589);
                if c1<>4 then sysmsg(590);
                sysmsg(591);
                if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                get('1234'+chr(13));
                if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                tch3:=ctmp;
                if tch3=chr(13) then begin sysmsg(584); exit; end;
                tstr[0]:=chr(1); tstr[1]:=tch3; c2:=str2int(tstr);
                if
                  (c2>4)
                or
                  (c2<1)
                or
                  (c1=c2)
                then
                  sysmsg(585)
                else
                  got:=true;
              until got or quitnow or lostcarrier;
              case c1 of
                1: begin parameter[1]:=g_sysmsg(593); t1:=user.stamina; end;
                2: begin parameter[1]:=g_sysmsg(594); t1:=user.skill; end;
                3: begin parameter[1]:=g_sysmsg(595); t1:=user.knowledge; end;
                4: begin parameter[1]:=g_sysmsg(596); t1:=user.talent; end;
              end;
              case c2 of
                1: parameter[2]:=g_sysmsg(593);
                2: parameter[2]:=g_sysmsg(594);
                3: parameter[2]:=g_sysmsg(595);
                4: parameter[2]:=g_sysmsg(596);
              end;
              sysmsg(592); {You wish to trade x for y, correct?}

              if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
              ctmp:=yn; ctmp:=upcase(ctmp);
              if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
              if
                ctmp='N'
              then
                exit;
              if
                ctmp='Y'
              then
                begin

              case c1 of
                1: parameter[1]:=locasestr(g_sysmsg(593));
                2: parameter[1]:=locasestr(g_sysmsg(594));
                3: parameter[1]:=locasestr(g_sysmsg(595));
                4: parameter[1]:=locasestr(g_sysmsg(596));
              end;
              parameter[2]:=int2str(t1);
              sysmsg(597);

                  if
                    t1<=10
                  then
                    sysmsg(598)
                  else
                    begin
                      parameter[1]:=int2str(t1-10);
                      sysmsg(599);
                      tstr:=getln(5);
                      tempc:=str2int(tstr);
                      ltmp:=tempc; ltmp:=ltmp*8; ltmp:=ltmp div 10;
                      sendln('');
                      if
                        (ltmp>(t1-10))
                      then
                        sysmsg(555)
                      else
                        begin

                          case c2 of
                            1: parameter[1]:=locasestr(g_sysmsg(593));
                            2: parameter[1]:=locasestr(g_sysmsg(594));
                            3: parameter[1]:=locasestr(g_sysmsg(595));
                            4: parameter[1]:=locasestr(g_sysmsg(596));
                          end;
                          parameter[2]:=int2str(ltmp);

                          sysmsg(600);
                          if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                          ctmp:=yn; ctmp:=upcase(ctmp);
                          if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                          if
                            ctmp='Y'
                          then
                            begin
                              case c2 of
                                1 : user.stamina:=user.stamina+ltmp;
                                2 : user.skill:=user.skill+ltmp;
                                3 : user.knowledge:=user.knowledge+ltmp;
                                4 : user.talent:=user.talent+ltmp;
                              end;
                              case c1 of
                                1: user.stamina:=user.stamina-tempc;
                                2: user.skill:=user.skill-tempc;
                                3: user.knowledge:=user.knowledge-tempc;
                                4: user.talent:=user.talent-tempc;
                              end;
                              sysmsg(601);
                            end;
                        end;
                    end;
                end;
            end;
      '4' : begin
              sysmsg(602);
              yndefault:=no;
              if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
              tch3:=yn; tch3:=upcase(tch3);
              if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
              if
                tch3='Y'
              then
                begin
                  user.jlosses:=0;
                  user.jwins:=0;
                  sysmsg(603);
                  parameter[1]:=mixedcase(user.name);
                  parameter[2]:=getgen(user.gender,2);
                  log(g_sysmsg(604));
                end
              else
                sendln('');
            end;
      '6' : begin
              yndefault:=no;
              sysmsg(605);
              if ansi then sendtext('BEHAVIOR.ANS') else sendtext('BEHAVIOR.ASC');
              parameter[1]:=int2str(user.attackmode);
              parameter[2]:=getamode(user.attackmode);
              sysmsg(606);
              if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
              get('123456'#13); tch3:=ctmp;
              if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
              tstr[0]:=chr(1); tstr[1]:=tch3;
              case tch3 of
                #13:exit;
                '1'..'6':user.attackmode:=str2int(tstr);
              end;
              sendln(getamode(str2int(tstr)));

              parameter[1]:=int2str(user.attackmode);
              parameter[2]:=getamode(user.attackmode);
              sysmsg(607);
            end;
      '5' : begin
              yndefault:=no;
              sysmsg(608);
              tch3:=yn; tch3:=upcase(tch3);
              if
                tch3='Y'
              then
                begin
                  sysmsg(609);
                  tch2:=yn; tch2:=upcase(tch2);
                  if
                    tch2='Y'
                  then
                    begin
                      temp1:=user.name;
                      temp2:=user.BBSname;
                      tempc:=user.playstoday;
                      default(user);
                      user.name:=temp1;
                      user.BBSname:=temp2;
                      user.playstoday:=tempc;
                      user.gender:=female;
                      got:=false;
                      repeat
                        if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                        begin
                          sysmsg(610);
                          if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                          get('mf?');
                          if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                          case upcase(ctmp) of
                            'M' : begin user.gender:=male; sysmsg(611); got:=true; end;
                            'F' : begin user.gender:=female; got:=true; sysmsg(612); end;
                            '?' : if ansi then sendtext('birdbees.ans') else sendtext('birdbees.asc');
                          end;
                        end;
                      until got or quitnow or lostcarrier;
                      if lostcarrier then begin nocarrier; quitnow:=true; exit; end;

                        {Orientation determination code}

                      sendln('`,');
                      user2.orientation:=straight;
                      got:=false;
                      repeat
                        begin
                          if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                          sysmsg(613);
                          get('sbg?');
                          if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                          case upcase(ctmp) of
                            'S' : begin user.orientation:=straight; got:=true; sysmsg(614); end;
                            'B' : begin user.orientation:=bi; got:=true; sysmsg(615); end;
                            'G' : begin user.orientation:=gay; got:=true; sysmsg(616); end;
                            '?' : if ansi then sendtext('birdbee2.ans') else sendtext('birdbee2.asc');
                          end;
                        end;
                      until got or quitnow or lostcarrier;
                      if lostcarrier then begin nocarrier; quitnow:=true; exit; end;
                      sysmsg(617);
                      parameter[1]:=mixedcase(user.name);
                      parameter[2]:=getgen(user.gender,3);
                      log(g_sysmsg(618));
                    end;
                end
              else
                sendln('');
            end;
    end; {case}
  until lostcarrier or quitnow;
end;
{
procedure newname;
var cost:comp;
    tch:char;
begin
  cost:=(user.level*user.level*50);
  parameter[1]:=int2str(cost);
  sysmsg(716);
  yndefault:=no;
  tch:=upcase(yn);
  if tch='N' then exit;
  if (user.gold<cost) then begin sysmsg(717); exit; end;
end;
}

begin
end.
