home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
GAMES
/
STARSHIP.ARC
/
STAR1.PRO
< prev
next >
Wrap
Text File
|
1989-09-27
|
8KB
|
271 lines
{ This file contains the cargo routines for the trading game STARSHIP}
{They are: forsale, buy, sell, showhold, showforsale}
{This is a turbo pascal source file}
procedure evaluate;
begin
for index:=1 to holdnum do if holdnow[index].category<>0 then
begin
with holdnow[index],galaxytrade[star] do
begin
num:=random(7)+random(5)+2;
(**) if (index=7) or (index=24) or (index=8) then num:=5+random(5);
if r then num:=num+arfactor;
if p then num:=num+apfactor;
if i then num:=num+aifactor;
if ni then num:=num+anifactor;
if a then num:=num+aafactor;
if na then num:=num+anafactor;
if num<1 then num:=1;
if num>14 then num:=14;
aprice:=aprice/(percent/100);{restore price to par}
realround(aprice);
percent:=fishrule(num);
aprice:=aprice*(percent/100);
end;{with}
end;{ifthen after fordo}
end;{procedure evaluate}
procedure strike;
begin
writeln;
if salary>0.2*credits then exit;
if (salary>0.05*credits) and (morale>100) and (random>0.3) then exit;
writeln('Your crew has gone on strike');
salary:=(random*random*random*salary*100/morale)+salary;
write('They demand ');
format(salary);
writeln(' credits a year');
morale:=morale-1;
moralebounce:=moralebounce-1;
writeln;
end;{procedure strike}
procedure lifeboats;
begin
writeln('You can always sell probes and lifeboats, and sometimes buy.');
writeln('Lifeboats cost forty thousand credits each, and sell for twenty.');
writeln('Probes cost sixty thousand, and sell for ten');
writeln(name,' now has ',boats,' small craft and ',probes,' probes.');
writeln('Will you:');
writeln('1. buy a lifeboat, 2. sell one, 3. buy a probe, 4. sell one, or 5. nothing');
inputs;
jndex:=inp;
case jndex of
1: begin
if boathere=true then begin
credits:=credits-4E4;
boats:=boats+1;
writeln('you now have ',boats,' boats');
end
else writeln('no boats here');
end;{case 1}
2: begin
if boats>0 then begin
boats:=boats-1;
writeln('you now have ',boats,' boats');
credits:=credits+20000;
end
else writeln('you have no boats to sell');
end; {case 2}
3: begin
if probehere=true then begin
credits:=credits-6E4;
probes:=probes+1;
writeln('you now have ',probes,' probes');
end
else writeln('no probes for sale');
end;{case 3}
4: begin
if probes>0 then begin
probes:=probes-1;
writeln('you now have ',probes,' probes');
credits:=credits+10000;
end
else writeln('no probes aboard the ',name);
end;{case 4}
5: ;
else writeln(chr(7),'wrong input, leaving lifeboat routine');
end;{case}
end;{lifeboats}
procedure showstars;
begin
writeln(' distance angle visited?');
for index:=1 to starmax do with galaxytrade[index] do
begin
if index<10 then write(' ');
write(index);
write(' ',starname,' ');
mndex:=0;
if r=true then begin write('R '); mndex:=mndex+2; end;
if p=true then begin write('P '); mndex:=mndex+2; end;
if a=true then begin write('A '); mndex:=mndex+2; end;
if na=true then begin write('NA '); mndex:=mndex+3; end;
if i=true then begin write('I '); mndex:=mndex+2; end;
if ni=true then begin write('NI '); mndex:=mndex+3; end;
for jndex:=mndex to 21 do write('.');
jndex:=distance[index]; {new use of jndex}
num:=angle[index];
if index<>thistar then write(jndex:3,' ',num:3)
else write('You are here');
if been[index]=false then write(' **');
writeln;
end;{with}
writeln('you have not been to stars marked "**"');
end;{showstars}
procedure forsale;
begin
writeln(' CARGOS FOR SALE ** CARGOS FOR SALE');
writeln(' dock # and cargo | price | weight | %of par value');
docks:=forsalenum;
if local6=true then docks:=docks+5;
for index:=1 to docks do
begin
jndex:=random(cargonum)+1;
with cargorange[jndex], availnow[index] do
begin
category:=jndex;
acargoname:=cargoname;
aunitnumber:=(random(8)+1);
(**) { bad programing warning! this should depend on the cargo file}
(**) if jndex>27 then aunitnumber:=aunitnumber+3;
(**) if jndex>13 then aunitnumber:=aunitnumber*5;
aprice:=unitprice*aunitnumber;
aweight:=weight*aunitnumber;
arfactor:=rfactor;
apfactor:=pfactor;
aifactor:=ifactor;
anifactor:=nifactor;
aafactor:=afactor;
anafactor:=nafactor;
end;{with}
with availnow[index],galaxytrade[star] do {adjust for local prices}
begin
num:=random(5)+random(5)+random(4)+1;
(**) if (index=7) or (index=24) or (index=8) then num:=5+random(5);
{7=sleds, 8=computers, 24=machine tools}
if r=true then num:=num+arfactor;
if p=true then num:=num+apfactor;
if i=true then num:=num+aifactor;
if ni=true then num:=num+anifactor;
if a=true then num:=num+aafactor;
if na=true then num:=num+anafactor;
if num<1 then num:=1;
if num>14 then num:=14;
percent:=fishrule(num);
realround(aprice);
aprice:=aprice*(percent/100);
write(' ',index,' ',acargoname);
format(aprice);
writeln(aweight:5,percent:8:0,'%');
end;{with}
end;{fordo}
end;{forsale}
procedure buy;
begin
index:=0; {find an empty hold}
repeat
index:=index+1;
if (index=holdnum) and (holdnow[index].category<>0) then
begin
writeln(chr(7),'no empty holds');
exit;
end;{ifthen}
until holdnow[index].category=0;
writeln('buy which cargo?');
inputs;
if (inp<1) or (inp>docks) then begin
writeln(chr(7),'wrong number');
exit;
end;{ifthen}
with availnow[inp] do
begin
if aweight>space then
begin
writeln(chr(7),'too heavy for the ',name,' to lift');
exit;
end;{ifthen}
if category=0 then writeln(chr(7),'you already bought that cargo')
else begin
if aprice>credits then
begin
writeln(chr(7),'not enough cash');
exit
end;{ifthen on aprice}
credits:=credits-aprice;
space:=space-availnow[inp].aweight;
holdnow[index]:=availnow[inp];
availnow[inp].category:=0;
t:=t-0.003;
end;{else}
end;{with}
end;{procedure buy}
procedure sell;
begin
writeln('Which hold number will you sell?');
inputs;
if (inp>holdnum) or (inp<1) then
begin
writeln(chr(7),'no such hold number');
exit;
end;{ifthen}
if holdnow[inp].category=0 then writeln(chr(7),'No cargo in that hold.')
else
begin
holdnow[inp].category:=0;
credits:=credits+holdnow[inp].aprice;
space:=space+holdnow[inp].aweight;
writeln('Your supercargo reports the transaction completed.');
t:=t-0.003;
end;{else}
end;
procedure showhold;
begin
writeln('Cargos stored in hold.........');
writeln('hold # and cargo | price | weight | %of par value');
messageflag:=true;
for index:=1 to 20 do
begin
with holdnow[index] do
if category>0 then
begin
write(index:2,' ',acargoname);
format(aprice);
writeln(aweight:5,percent:8:0,'%');
messageflag:=false;
end;{ifthen}
end;{fordo}
if messageflag=true then
begin
writeln('All cargo spaces are empty.');
if credits<(-10000*probes-20000*boats) then begin
writeln('And you are bankrupt. Better luck in some other profession.');
halt;
end;{ifthen on credits}
end;{ifthen on messageflag}
end;{showhold}
procedure showforsale;
begin
writeln(' CARGOS FOR SALE ** CARGOS FOR SALE');
writeln(' dock # and cargo | price | weight | %of par value');
messageflag:=true;
for index:=1 to docks do
begin
with availnow[index] do
if category>0 then
begin
messageflag:=false;
write(' ',index:2,' ',acargoname);
format(aprice);
writeln(aweight:5,percent:8:0,'%');
end;{ifthen}
end;{fordo}
if messageflag=true then writeln('Nothing left for sale.');
end;{showforsale}