uses crt;
var
i,levelup,exp:longint;
er,exitlevel,boss,swampp,mount,deff:integer;
tab:string;
savefile,loadfile:text;
par:array[1..9] of string;
sch:integer;
ch:char;
r,p,m,hp,dm,cur,luk,ex,money,monster,mhp,mdm,gold,life,lvl,mg:integer;
el,poc1,poc2,quest,ellif,elsil,pb,pa,ma,mb,mpoc1,mpoc2,kill,dead,d:integer;
rasa,dey,at,bl,dial,adres:string;
key:char;
fight,prohod,exitmenu:boolean;
gor:longint;
const
r1r='-----------';
z=' ';
procedure load;
begin
 sch:=1;
 clrscr;
 writeln(r1r,r1r);
 textcolor(yellow);
 writeln('If you want load game, from that directory, where is this game  ');
 writeln('write only a name of load-file');
 textcolor(white);
 writeln(r1r,r1r);
 writeln('Please, write directory.');
 readln(adres);
 assign(loadfile,adres+'.sav');
 reset(loadfile);
 read(loadfile,lvl,hp,poc2,poc1,exp,r,kill,dead,boss,exitlevel,swampp,mount,deff,ellif,elsil);
 close(loadfile);
 if r=1 then rasa:='human';
 if r=2 then rasa:='elf';
 if r=3 then rasa:='ork';
 if r=4 then rasa:='lizard';
end;
procedure save;
begin
 clrscr;
 writeln(r1r,r1r);
 textcolor(yellow);
 writeln('If you want save game, in that directory, where is this game  ');
 writeln('write only a name of save-file');
 textcolor(white);
 writeln(r1r,r1r);
 writeln('Please, write directory.');
 readln(adres);
 assign(savefile, adres+'.sav');
 rewrite(savefile);
 write(savefile,lvl,z, hp,z, poc2,z, poc1,z, exp,z, r,z, kill,z, dead,z,boss,z,exitlevel,z,swampp,z,mount,z,deff,z,
 ellif,z,elsil);
 close(savefile);
end;
procedure menu;
begin
 exitmenu:=false;
 repeat
 clrscr;
 gotoxy(7,1);
 textcolor(yellow);
 writeln('Main menu');
 textcolor(white);
 writeln(r1r,r1r);
 write('Contining game ');
 textcolor(yellow);
 writeln('[CON]');
 textcolor(white);
 write('Save game ');
 textcolor(yellow);
 writeln('[SAVE]');
 textcolor(white);
 write('Load game ');
 textcolor(yellow);
 writeln('[LOAD]');
 textcolor(white);
 readln(dey);
 if dey='con' then exitmenu:=true;
 if dey='save' then save;
 if dey='load' then load;
 until exitmenu=true;
end;
procedure dialmonk(var boss:integer);
begin
 repeat
 clrscr;
 writeln('Hello, what do you want from me?');
 writeln(r1r,r1r);
 write('I want speak about my mission ');
 textcolor(yellow);
 writeln('[M]');
 textcolor(white);
 write('Goodbye ');
 textcolor(yellow);
 writeln('[G]');
 textcolor(white);
 dial:=readkey;
 if dial='g' then d:=2;
 if dial='m' then d:=1;
 if d=2 then writeln('Goodbye');
 if d=1  then
 begin
  repeat
  if prohod=false then
  begin
   clrscr;
   writeln('To become a paladin you mast kill an owner of old castle');
   writeln(r1r,r1r);
   write('OK. I will kill him. ');
   textcolor(yellow);
   writeln('[G]');
   textcolor(white);
   dial:=readkey;
   if dial='g' then d:=2;
  end;
 if prohod=true then
 begin
  clrscr;
  writeln('Oh, I see you kill him. So, now you become a paladin.');
  writeln('And now you mast go to the Hell and kill a powerfull demon.');
  writeln('I have already open portal, so you can go.');
  writeln(r1r,r1r);
  write('Ok. I''m ready ');
  textcolor(yellow);
  writeln('[R]');
  boss:=1;
  textcolor(white);
  dial:=readkey;
  if dial='r' then d:=2;
 end;
 until d<>1;
 end;
 repeat until keypressed;
 until d=2;
end;
procedure test;
begin
 mhp:=500;
 mpoc1:=10;
 mpoc2:=1;
 ex:=600;
 gold:=0;
 writeln('You see defender of tower (lv 5)');
 writeln('Hp:',mhp);
 writeln('Dm: 1-10 ');
end;
procedure monster18;
begin
 mhp:=550;
 mpoc1:=17;
 mpoc2:=4;
 ex:=650;
 gold:=130;
 writeln('You see a gidre (lv 7)');
 writeln('Hp:',mhp);
 writeln('Dm: 4-20 ');
end;
procedure monster17;
begin
 mhp:=400;
 mpoc1:=15;
 mpoc2:=1;
 ex:=480;
 gold:=98;
 writeln('You see a small gidre (lv 5)');
 writeln('Hp:',mhp);
 writeln('Dm: 1-15 ');
end;
procedure monster16;
begin
 mhp:=350;
 mpoc1:=10;
 mpoc2:=4;
 ex:=420;
 gold:=84;
 writeln('You see an old swamp''s crocodile (lv 5)');
 writeln('Hp:',mhp);
 writeln('Dm: 4-10 ');
end;
procedure monster15;
begin
 mhp:=200;
 mpoc1:=8;
 mpoc2:=1;
 ex:=245;
 gold:=59;
 writeln('You see an swamp''s crocodile (lv 4)');
 writeln('Hp:',mhp);
 writeln('Dm: 1-8 ');
end;
procedure monster14;
begin
 mhp:=650;
 mpoc1:=21;
 mpoc2:=0;
 ex:=750;
 gold:=117;
 writeln('You see an lich (lv 9)');
 writeln('Hp:',mhp);
 writeln('Dm: 0-20 ');
end;
procedure boss1;
begin
 mhp:=750;
 mpoc1:=11;
 mpoc2:=5;
 ex:=850;
 gold:=170;
 writeln('You see a dark magister, owner of this castle (lv 10)');
 writeln('Hp:',mhp);
 writeln('Dm: 5-15 ');
end;
procedure monster13;
begin
 mhp:=500;
 mpoc1:=4;
 mpoc2:=7;
 ex:=585;
 gold:=117;
 writeln('You see an skeleton (lv 7)');
 writeln('Hp:',mhp);
 writeln('Dm: 7-10 ');
end;
procedure monster12;
begin
 mhp:=750;
 mpoc1:=26;
 mpoc2:=15;
 ex:=1050;
 gold:=210;
 writeln('You see an old dragon (lv 10)');
 writeln('Hp:',mhp);
 writeln('Dm: 15-45 ');
end;
procedure monster11;
begin
 mhp:=500;
 mpoc1:=21;
 mpoc2:=10;
 ex:=650;
 gold:=130;
 writeln('You see a dragon (lv 8)');
 writeln('Hp:',mhp);
 writeln('Dm: 10-30 ');
end;
procedure monster10;
begin
 mhp:=120;
 mpoc1:=5;
 mpoc2:=5;
 ex:=185;
 gold:=34;
 writeln('You see a garpie (lv 3)');
 writeln('Hp:',mhp);
 writeln('Dm: 4-9 ');
end;
procedure monster9;
begin
 mhp:=150;
 mpoc1:=11;
 mpoc2:=3;
 ex:=220;
 gold:=54;
 writeln('You see a gorguly (lv 5)');
 writeln('Hp:',mhp);
 writeln('Dm: 3-13');
end;
procedure shandow;
begin
 mhp:=hp;
 mpoc1:=poc1;
 mpoc2:=poc2;
 ex:=2*(hp+(poc1+poc2)*5);
 writeln('You see a your''s shandow (lv ',lvl,')');
 writeln('Hp:',hp);
 writeln('Dm: ',poc2,'-',poc1);
end;
procedure monster8;
begin
 mhp:=220;
 mpoc1:=6;
 mpoc2:=10;
 ex:=355;
 gold:=71;
 writeln('You see a king wurm (lv 6)');
 writeln('Hp:',mhp);
 writeln('Dm: 10-15');
end;
procedure monster7;
begin
 mhp:=150;
 mpoc1:=5;
 mpoc2:=8;
 ex:=250;
 gold:=50;
 writeln('You see an old wurm (lv 5)');
 writeln('Hp:',mhp);
 writeln('Dm: 8-12');
end;
procedure monster6;
begin
 mhp:=100;
 mpoc1:=4;
 mpoc2:=5;
 ex:=165;
 gold:=33;
 writeln('You see a wurm (lv 5)');
 writeln('Hp:',mhp);
 writeln('Dm: 5-8');
end;
procedure monster5;
begin
 mhp:=60;
 mpoc1:=3;
 mpoc2:=3;
 ex:=100;
 gold:=20;
 writeln('You see a headhunter(lv 4)');
 writeln('Hp:',mhp);
 writeln('Dm: 3-5');
end;
procedure monster4;
begin
 mhp:=70;
 mpoc1:=1;
 mpoc2:=1;
 ex:=85;
 gold:=15;
 writeln('You see an ent (lv 3)');
 writeln('Hp: ',mhp);
 writeln('Dm: 1-2');
end;
procedure monster3;
begin
 mhp:=50;
 mpoc1:=4;
 mpoc2:=1;
 ex:=80;
 gold:=15;
 writeln('You see an ent(lv 3)');
 writeln('Hp: ',mhp);
 writeln('Dm: 1-5');
end;
procedure monster2;
begin
 mhp:=25;
 mpoc1:=3;
 mpoc2:=3;
 ex:=65;
 gold:=11;
 writeln('You see a wolf(lv 2)');
 writeln('Hp: ',mhp);
 writeln('Dm: 3-5');
end;
procedure monster1;
begin
 mhp:=15;
 mpoc1:=1;
 mpoc2:=3;
 ex:=35;
 gold:=7;
 writeln('You see a wolf(lv 1)');
 writeln('Hp: ',mhp);
 writeln('Dm: 1-3');
end;
procedure boi;
begin
 randomize;
 dm:=random(poc1)+poc2;
 mdm:=random(mpoc1)+mpoc2;
 pa:=0;
 pb:=0;
 clrscr;
 writeln('You have: ',life);
 writeln('Monster have: ',mhp);
 writeln(r1r,r1r);
 writeln('Attack to ');
 write('Head ');
 textcolor(yellow);
 writeln('[H]');
 textcolor(white);
 write('Body ');
 textcolor(yellow);
 writeln('[B]');
 textcolor(white);
 write('Legs ');
 textcolor(yellow);
 writeln('[L]');
 textcolor(white);
 at:=readkey;
 if at='h' then pa:=1;
 if at='b' then pa:=2;
 if at='l' then pa:=3;
 if (pa>0) and (pa<4) then
 begin
  clrscr;
  writeln('You have: ',life);
  writeln('Monster have: ',mhp);
  writeln(r1r,r1r);
  writeln('Block to ');
  write('Head ');
  textcolor(yellow);
  writeln('[H]');
  textcolor(white);
  write('Body ');
  textcolor(yellow);
  writeln('[B]');
  textcolor(white);
  write('Legs ');
  textcolor(yellow);
  writeln('[L]');
  textcolor(white);
  bl:=readkey;
  if bl='h' then pb:=1;
  if bl='b' then pb:=2;
  if bl='l' then pb:=3;
  if (pb>0) and (pb<4) then
  begin
   ma:=random(3)+1;
   mb:=random(3)+1;
   if pa<>mb then mhp:=mhp-dm;
   if pb<>ma then life:=life-mdm;
  end;
 end;
end;
procedure runaway;
begin
 writeln('You run away');
 writeln('You loose 50 exp');
 exp:=exp-50;
 repeat until keypressed;
end;
procedure expifor;
begin
 writeln('You saw a stone. When you take it...');
 ex:=random(30)+1;
 exp:=exp+ex;
 writeln('You get ',ex,' exp');
 repeat until keypressed;
end;
procedure monifor;
begin
 writeln('You find some money.');
 ex:=random(10)+1;
 money:=money+ex;
 writeln('You get ',ex,' money');
 repeat until keypressed;
end;
procedure loose;
begin
 textcolor(red);
 writeln('YOU LOOSE');
 textcolor(white);
 writeln('You loose all your money.');
 money:=0;
 writeln('You loose 200 exp.');
 exp:=exp-200;
 dead:=dead+1;
end;
procedure win;
begin
 textcolor(green);
 writeln('YOU WIN');
 textcolor(white);
 exp:=exp+ex;
 write('You''ve got ');
 textcolor(yellow);
 write(ex);
 textcolor(white);
 writeln(' exp');
 writeln('Now you have: ', exp, ' exp');
 money:=money+gold;
 write('You''ve got ');
 textcolor(yellow);
 write(gold);
 textcolor(white);
 writeln(' money');
 writeln('Now you have: ', money,' money');
 kill:=kill+1;
 if monster=0 then
 begin
  textcolor(yellow);
  writeln('You killed an owner of old castle!');
  writeln('And now evil go away from this land!');
  textcolor(white);
  prohod:=true;
  boss:=1;
 end;
 repeat until keypressed;
end;
procedure level1;
begin
repeat
if p=1 then
begin
 repeat
 clrscr;
 writeln('You stay in the forest. What do you want to do?');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Hunt ');
 textcolor(yellow);
 writeln('[H]');
 textcolor(white);
 if swampp=1 then
 begin
  write('Go to the swamp ');
  textcolor(yellow);
  writeln('[S]');
  textcolor(white);
 end;
 write('Go to the castle ');
 textcolor(yellow);
 writeln('[C]');
 textcolor(white);
 write('Go to the village ');
 textcolor(yellow);
 writeln('[V]');
 textcolor(white);
 dey:=readkey;
 if (dey='s') and (swampp=1) then p:=5;
 if dey='v' then p:=2;
 if dey='c' then p:=9;
 if dey='h' then
 begin
  writeln('You go hunt...');
  luk:=random(20)+1;
  if (luk=20) and (swampp=0) then
  begin
  textcolor(yellow);
  writeln('You find new location!');
  textcolor(white);
  swampp:=1;
  repeat until keypressed;
  end;
  if (luk=20) and (swampp=1) then luk:=19;
  if (luk=19) or (luk=18) then expifor;
  if (luk=17) or (luk=16) then monifor;
  if luk<16 then
  begin
   writeln('You see a monster!');
   monster:=random(4)+1;
   begin
    if monster=1 then monster1;
    if monster=2 then monster2;
    if monster=3 then monster3;
    if monster=4 then monster4;
   end;
  writeln('You can:');
  write('Fight ');
  textcolor(yellow);
  writeln('[F]');
  textcolor(white);
  write('Run ');
  textcolor(yellow);
  writeln('[R]');
  textcolor(white);
  dey:=readkey;
  if dey='r' then fight:=false;
  if dey='f' then fight:=true;
  if fight=false then runaway;
  if fight=true then
   begin
    life:=hp;
    repeat
    boi;
    until (life<=0) or (mhp<=0);
    repeat
    if life<0 then loose;
    if (mhp<=0) and (life>0) then win;
    until keypressed;
   end;
  end;
end;
until p<>1;
end;
if p=2 then
begin
  repeat
  clrscr;
  writeln('You stay in the villiage.');
  textcolor(green);
  writeln(r1r,r1r);
  textcolor(white);
  if prohod=true then
  begin
   write('Use teleport to the Hell ');
   textcolor(yellow);
   writeln('[H]');
  end;
  textcolor(white);
  write('Go to Arena ');
  textcolor(yellow);
  writeln('[A]');
  textcolor(white);
  write('Go to the forest ');
  textcolor(yellow);
  writeln('[F]');
  textcolor(white);
  write('Go to the plaints ');
  textcolor(yellow);
  writeln('[P]');
  textcolor(white);
  write('Go to mountains ');
  textcolor(yellow);
  writeln('[M]');
  textcolor(white);
  write('Go to the guild ');
  textcolor(yellow);
  writeln('[G]');
  textcolor(white);
  write('Go to the church ');
  textcolor(yellow);
  writeln('[C]');
  textcolor(white);
  writeln(r1r,r1r);
  write('Main menu ');
  textcolor(yellow);
  writeln('[MENU]');
  textcolor(white);
  write('Exit ');
  textcolor(yellow);
  writeln('[E]');
  textcolor(white);
  dey:=readkey;
  if dey='e' then exit;
  if dey='menu' then menu;
  if dey='f' then p:=1;
  if dey='g' then p:=3;
  if dey='c' then p:=4;
  if dey='p' then p:=6;
  if dey='a' then p:=7;
  if dey='m' then p:=8;
  if (dey='h') and (boss=1) then exitlevel:=1;
  until p<>2;
end;
if p=3 then
begin
 repeat
 clrscr;
 writeln('You stay in the guid');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Go to the village ');
 textcolor(yellow);
 writeln('[V]');
 textcolor(white);
 writeln(r1r);
 write('Buy power(',elsil,' money) ');
 textcolor(yellow);
 writeln('[P]');
 textcolor(white);
 write('Buy health(',ellif,' money) ');
 textcolor(yellow);
 writeln('[H]');
 textcolor(white);
 dey:=readkey;
 if dey='v' then p:=2;
 if dey='p' then
 begin
  if money<elsil then
  begin
   textcolor(lightred);
   writeln('You haven''t so much money!');
   textcolor(white);
   writeln('You have only ',money);
   write('You must colleced ');
   textcolor(yellow);
   write(elsil-money);
   textcolor(white);
   writeln(' more');
   repeat until keypressed;
  end;
  if money>=elsil then
  begin
   elsil:=elsil+5;
   textcolor(lightgreen);
   writeln('You buy it');
   textcolor(white);
   money:=money-elsil;
   writeln('Now you become stronger!');
   if el=0 then
   poc2:=poc2+1;
   poc1:=poc1+1;
   write('Your damage ',poc2,'-',poc1);
   repeat until keypressed;
   end;
  end;
  if dey='h' then
  begin
   if money<ellif then
   begin
    textcolor(lightred);
    writeln('You haven''t so much money!');
    textcolor(white);
    writeln('You have only ',money);
    write('You must colleced ');
    textcolor(yellow);
    write(ellif-money);
    textcolor(white);
    writeln(' more');
    repeat until keypressed;
   end;
   if money>=ellif then
   begin
    ellif:=ellif+5;
    textcolor(lightgreen);
    writeln('You buy it');
    textcolor(white);
    money:=money-ellif;
    writeln('You become healther!');
    hp:=hp+5;
    writeln('Now you have ',hp);
    repeat until keypressed;
   end;
  end;
until p<>3;
end;
if p=4 then
begin
 repeat
 clrscr;
 writeln('You stay in the church');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Go to the village ');
 textcolor(yellow);
 writeln('[V]');
 textcolor(white);
 write('Level up ');
 textcolor(yellow);
 writeln('[L]');
 textcolor(white);
 write('Statistic ');
 textcolor(yellow);
 writeln('[S]');
 textcolor(white);
 write('Speak with the monk ');
 textcolor(yellow);
 writeln('[M]');
 textcolor(white);
 dey:=readkey;
 if dey='v' then p:=2;
 if dey='m' then dialmonk(boss);
 if dey='s' then
 begin
  clrscr;
  textcolor(yellow);
  gotoxy(7,1);
  writeln('STATISTIC');
  textcolor(white);
  writeln(r1r,r1r);
  write('You kill ');
  textcolor(red);
  write(kill);
  textcolor(white);
  writeln(' monsters');
  write('You dead ');
  textcolor(red);
  write(dead);
  textcolor(white);
  writeln(' times');
  writeln(r1r,r1r);
  write('You have ');
  textcolor(yellow);
  write(exp);
  textcolor(white);
  writeln(' exp');
  write('You have ');
  textcolor(yellow);
  write(money);
  textcolor(white);
  writeln(' money');
  write('You have ');
  textcolor(yellow);
  write(hp);
  textcolor(white);
  writeln(' hp');
  write('Your damage is ');
  textcolor(yellow);
  writeln(poc2,'-',poc1);
  textcolor(white);
  repeat until keypressed;
 end;
 if dey='l' then
 begin
  clrscr;
  if exp>=levelup then
  begin
   repeat
   clrscr;
   lvl:=lvl+1;
   hp:=hp+5;
   writeln('You level up!');
   writeln(r1r,r1r);
   write('Now you have ');
   textcolor(yellow);
   write(hp);
   textcolor(white);
   writeln(' hp');
   writeln(r1r,r1r);
   if lvl>1 then levelup:=levelup+200+50*lvl;
   until exp<levelup;
  end;
  write('Now you ');
  textcolor(yellow);
  write(lvl);
  textcolor(white);
  writeln(' level');
  writeln('And you have ',exp,' exp');
  write('To level up you must colleced ');
  textcolor(yellow);
  write(levelup);
  textcolor(white);
  writeln(' exp');
  repeat until keypressed;
 end;
  until p<>4;
end;
if p=5 then
begin
repeat
 clrscr;
 writeln('You stay in the swamp');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Go to the forest ');
 textcolor(yellow);
 writeln('[F]');
 textcolor(white);
 write('Hunt ');
 textcolor(yellow);
 writeln('[H]');
 textcolor(white);
 dey:=readkey;
 if dey='f' then p:=1;
 if dey='h' then
 begin
  writeln('You see a monster!');
  monster:=random(4)+1;
  begin
   if monster=1 then monster15;
   if monster=2 then monster16;
   if monster=3 then monster17;
   if monster=4 then monster18;
  end;
  writeln('You can:');
  write('Fight ');
  textcolor(yellow);
  writeln('[F]');
  textcolor(white);
  write('Run ');
  textcolor(yellow);
  writeln('[R]');
  textcolor(white);
  dey:=readkey;
  if dey='r' then fight:=false;
  if dey='f' then fight:=true;
  if fight=false then runaway;
  if fight=true then
   begin
    life:=hp;
    repeat
    boi;
    until (life<=0) or (mhp<=0);
    if life<0 then loose;
    if (mhp<=0) and (life>0) then win;
    repeat until keypressed;
   end;
  end;
 until p<>6;
end;
if p=6 then
begin
 repeat
 clrscr;
 writeln('You stay in the plaints');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Go to the village ');
 textcolor(yellow);
 writeln('[V]');
 textcolor(white);
 write('Hunt ');
 textcolor(yellow);
 writeln('[H]');
 textcolor(white);
 dey:=readkey;
 if dey='v' then p:=2;
 if dey='h' then
 begin
  writeln('You go hunt...');
  luk:=random(10)+1;
  if luk=10 then expifor;
  if luk=9 then monifor;
  if luk<9 then
  begin
   writeln('You see a monster!');
   monster:=random(4)+1;
   begin
    if monster=1 then monster5;
    if monster=2 then monster6;
    if monster=3 then monster7;
    if monster=4 then monster8;
   end;
   writeln('You can:');
   write('Fight ');
   textcolor(yellow);
   writeln('[F]');
   textcolor(white);
   write('Run ');
   textcolor(yellow);
   writeln('[R]');
   textcolor(white);
   dey:=readkey;
   if dey='r' then fight:=false;
   if dey='f' then fight:=true;
   if fight=false then runaway;
   if fight=true then
    begin
     life:=hp;
     repeat
     boi;
     until (life<=0) or (mhp<=0);
     if life<0 then loose;
     if (mhp<=0) and (life>0) then win;
    repeat until keypressed;
    end;
   end;
  end;
 until p<>6;
end;
if p=7 then
begin
 repeat
 clrscr;
 writeln('You stay on the Arena');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Go to the village ');
 textcolor(yellow);
 writeln('[V]');
 textcolor(white);
 write('Fight ');
 textcolor(yellow);
 writeln('[F]');
 textcolor(white);
 dey:=readkey;
 if dey='v' then p:=2;
 if dey='f' then
 begin
  clrscr;
  writeln('With who do you want to fight?');
  writeln(r1r);
  write('Shandow ( ' ,lvl,'lv )' );
  textcolor(yellow);
  writeln('[S]');
  textcolor(white);
  monster:=5;
  readln(dey);
  if dey='s' then shandow;
  life:=hp;
  repeat
  boi;
  until (life<=0) or (mhp<=0);
  if life<=0 then loose;
  if life>0 then win;
  repeat until keypressed;
 end;
 until p<>7;
end;
if p=8 then
begin
 repeat
 clrscr;
 m:=0;
 writeln('You stay in the mounteins. What do you want to do?');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Hunt ');
 textcolor(yellow);
 writeln('[H]');
 if mount=1 then
 begin
  textcolor(white);
  write('Go to the Tower ');
  textcolor(yellow);
  writeln('[T]');
 end;
 textcolor(white);
 write('Go to the village ');
 textcolor(yellow);
 writeln('[V]');
 textcolor(white);
 dey:=readkey;
 if (dey='t') and (mount=1) then p:=10;
 if dey='v' then p:=2;
 if dey='h' then
 begin
  writeln('You go hunt...');
  luk:=random(15)+1;
  if (luk>12) and (mount=0) then
  begin
   textcolor(yellow);
   writeln('You find new location');
   textcolor(white);
   mount:=1;
   repeat until keypressed;
  end;
  if (luk<13) or ((mount=1) and (luk>12)) then
  begin
   writeln('You see a monster!');
   monster:=random(4)+1;
   begin
    if monster=1 then monster10;
    if monster=2 then monster9;
    if monster=3 then monster11;
    if monster=4 then monster12;
   end;
  writeln('You can:');
  write('Fight ');
  textcolor(yellow);
  writeln('[F]');
  textcolor(white);
  write('Run ');
  textcolor(yellow);
  writeln('[R]');
  textcolor(white);
  dey:=readkey;
  if dey='r' then fight:=false;
  if dey='f' then fight:=true;
  if fight=false then runaway;
  if fight=true then
  begin
   life:=hp;
   repeat
   boi;
   until (life<=0) or (mhp<=0);
   if life<0 then loose;
   if (mhp<=0) and (life>0) then win;
   repeat  until keypressed;
   end;
  end;
 end;
 until p<>8;
end;
if p=9 then
begin
 repeat
 clrscr;
 writeln('You stay in the old castle. What do you want to do?');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Explore ');
 textcolor(yellow);
 writeln('[E]');
 textcolor(white);
 write('Go to the forest ');
 textcolor(yellow);
 writeln('[F]');
 textcolor(white);
 dey:=readkey;
 if dey='f' then p:=1;
 if dey='e' then
 begin
  luk:=random(5)+1;
  if luk=5 then
  begin
   writeln('You find a money');
   m:=random(200)+1;
   writeln('You find ',m);
   money:=money+m;
   repeat until keypressed;
  end;
  if luk<>5 then
  begin
   clrscr;
   writeln('You see a monster!');
   monster:=random(4)+1;
   begin
    if monster=1 then monster13;
    if monster=2 then monster13;
    if monster=3 then monster14;
    if monster=4 then
    begin
     if boss=0 then
     begin
      boss1;
      monster:=0;
     end;
    if boss=1 then monster14;
    end;
   end;
   writeln('You can:');
   write('Fight ');
   textcolor(yellow);
   writeln('[F]');
   textcolor(white);
   write('Run ');
   textcolor(yellow);
   writeln('[R]');
   textcolor(white);
   dey:=readkey;
   if dey='r' then fight:=false;
   if dey='f' then fight:=true;
   if fight=false then runaway;
   if fight=true then
   begin
    life:=hp;
    repeat
    boi;
    until (life<=0) or (mhp<=0);
    if life<0 then loose;
    if (mhp<=0) and (life>0) then win;
    repeat  until keypressed;
   end;
  end;
  end;
 until p<>9;
end;
if p=10 then
begin
 repeat
 clrscr;
 writeln('You stay in God''s tower');
 textcolor(green);
 writeln(r1r,r1r);
 textcolor(white);
 write('Pass test ');
 textcolor(yellow);
 writeln('[T]');
 textcolor(white);
 write('Go yo the mounteins ');
 textcolor(yellow);
 writeln('[M]');
 textcolor(white);
 dey:=readkey;
 if dey='m' then p:=8;
 if (dey='t') and (deff=0) then
 begin
 test;
 repeat
 boi
 until (life<=0) or (mhp<=0);
 if life<=0 then loose;
 if (life>0) and (mhp<=0) then
 begin
  clrscr;
  textcolor(yellow);
  writeln('You have resived God''s blesing');
  textcolor(white);
  hp:=hp+50;
  writeln('You''ve get +50 hp');
  writeln('You''ve get +10 dmg');
  poc1:=poc1+10;
  deff:=1;
  repeat until keypressed;
 end;
 if (dey='t') and (deff=1) then
 begin
  writeln('You have already got it!');
  repeat until keypressed;
  end;
 end;
 until p<>10;
end;
until exitlevel=1;
clrscr;
textcolor(yellow+blink);
gotoxy(7,1);
writeln('!!! You win !!!');
textcolor(green);
writeln(r1r,r1r);
textcolor(white);
write('Author: ');
textcolor(yellow);
writeln('yazer');
textcolor(white);
writeln('yazer@i.ua');
repeat until keypressed;
end;
procedure game;
begin
 write('You have: ');
 textcolor(yellow);
 write(hp);
 textcolor(white);
 writeln(' hp');
 write('You damage is ');
 textcolor(yellow);
 writeln(poc2,'-',poc1);
 textcolor(white);
 repeat until keypressed;
 level1;
end;
procedure lizard;
 begin
 hp:=5000;
 poc1:=600;
 poc2:=100;
 game;
 end;
procedure human;
 begin
 hp:=40;
 poc1:=9;
 poc2:=1;
 game;
 end;
procedure elf;
 begin
 hp:=30;
 poc1:=15;
 poc2:=2;
 game;
 end;
procedure ork;
 begin
 hp:=50;
 poc1:=6;
 poc2:=1;
 game;
 end;
procedure index;
begin
 p:=2;
 money:=0;
 exp:=0;
 lvl:=1;
 prohod:=false;
 levelup:=250;
 quest:=1;
 ellif:=35;
 elsil:=50;
 repeat
 clrscr;
 writeln('Who are you?');
 write('human ');
 textcolor(yellow);
 writeln('[h]');
 textcolor(white);
 write('elf ');
 textcolor(yellow);
 writeln('[e]');
 textcolor(white);
 write('ork ');
 textcolor(yellow);
 writeln('[o]');
 textcolor(white);
 r:=0;
 rasa:=readkey;
 if rasa='h' then r:=1;
 if rasa='e' then r:=2;
 if rasa='o' then r:=3;
 if rasa='lizard' then r:=4;
 until r<>0;
 if r=1 then human;
 if r=2 then elf;
 if r=3 then ork;
 if r=4 then lizard;
 end;
procedure logo;
begin
 textcolor(white);
 clrscr;
 writeln(r1r);
 write('|  ');
 textcolor(yellow);
 write('quest');
 textcolor(white);
 writeln('  |');
 writeln(r1r);
 repeat until keypressed;
 index;
end;
begin
 randomize;
 logo;
end.