Advertisement
Guest User

Untitled

a guest
Apr 6th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 5.21 KB | None | 0 0
  1. program project1;
  2.  
  3. uses
  4. crt;
  5.  
  6.  
  7. var
  8.   inc, rnd1 ,rnd2,jbc,sec, pris ,stats, bank, turn : integer;
  9.   key,key1,key2,key3:char;
  10.  
  11. procedure etc;
  12. begin
  13. writeln('Daily income: ',inc,' cash.');
  14. writeln('Bank: ',bank);
  15. writeln('--------------------------------------');
  16. end;
  17.  
  18. procedure etc1;
  19. begin
  20. writeln('Starting day number ',turn,'.');
  21. writeln('Bank: ',bank);
  22. writeln('Prisoners: ',pris);
  23. writeln('Daily income: ',inc);
  24. writeln('Security level: ',sec);
  25. end;
  26.  
  27. begin
  28.   repeat
  29.   sec := 0;
  30.   jbc := 7;
  31.   turn := 0;
  32.   bank := 0;
  33.   stats := 0;
  34.   pris := 2;
  35.   inc := 150;
  36.   writeln('Hello and welcome to the JailBreak game made by Sami.');
  37.   readln;
  38.   writeln('Instructions: ');
  39.   writeln('-Feed your prisoners day by day (if possible).');
  40.   writeln('-If the unsatisfied prisoners count gets over 3 your');
  41.   writeln('daily income will start to decrease.');
  42.   writeln('-You can buy a new prisoner from Menu(M) or increase');
  43.   writeln('the security system, thus decreasing canche of jailbreak');
  44.   writeln('If you get -300 cash you will lose the game.');
  45.   writeln('The goal of the game is to have 5 prisoners in less days.');
  46.   readln;
  47.   writeln('Ready to play?[press <ENTER> to start the first day.]');
  48.   readln;
  49.  {-Starting the routine-}
  50.   begin
  51.   repeat
  52.   randomize;
  53.   rnd1 := random(3);
  54.   rnd2 := random(jbc);
  55.  
  56.   if (rnd1 = 1) then begin
  57.   clrscr;
  58.   turn := turn + 1;
  59.   etc1;
  60.   repeat
  61.     write(pris,' prisoners are hungry. Feed them? (Y/N): ');
  62.     readln(key);
  63.     key := upcase(key);
  64.     until (key = 'Y') or (key = 'N');
  65.  
  66.     if (key = 'N') then begin
  67.     stats := stats - 2;
  68.     writeln('--------------------------------------');
  69.     writeln('The prisoners are not satisfied for today!');
  70.     writeln('Unsatisfied prisoners count: ',stats);
  71.     end;
  72.  
  73.     if (key = 'Y') then begin
  74.     stats := stats + 2;
  75.     writeln('--------------------------------------');
  76.     writeln('Good job! the prisoners are fullfiled for today!');
  77.     bank := bank - 150;
  78.     writeln('-150 cash');
  79.     writeln('Satisfied prisoners count: ',stats);
  80.     bank := bank + inc;
  81.     etc;
  82.   end;
  83.  end;
  84.  
  85.   if (rnd1 = 2) then begin
  86.   turn := turn + 1;
  87.     clrscr;
  88.     etc1;
  89.     repeat
  90.     write(pris-1,' prisoner is hungry. Feed him? (Y/N): ');
  91.     readln(key);
  92.     key := upcase(key);
  93.     until (key = 'Y') or (key = 'N');
  94.  
  95.     if (key = 'N') then begin
  96.     stats := stats - 1;
  97.     writeln('--------------------------------------');
  98.     writeln('The prisoner is not satisfied for today!');
  99.     writeln('Unsatisfied prisoners count: ',stats);
  100.     end;
  101.  
  102.     if (key = 'Y') then begin
  103.     stats := stats + 1;
  104.     writeln('--------------------------------------');
  105.     writeln('Good job! the prisoners are fullfiled for today!');
  106.     bank := bank - 100;
  107.     writeln('-100 cash');
  108.     writeln('Satisfied prisoners count: ',stats);
  109.       bank := bank + inc;
  110.       etc;
  111.  end;
  112. end;
  113.  
  114.   if (rnd1 = 3) then begin
  115.   turn := turn + 1;
  116.   clrscr;
  117.   etc1;
  118.   writeln('--------------------------------------');
  119.   write('No prisoner is hungry today, you are lucky!');
  120.   bank := bank + inc;
  121.   etc;
  122.   end;
  123. {-Ending the routine-}
  124.  
  125. {--------------------}
  126.  
  127. {-Deciding either -inc or staying the same-}
  128.   if (stats < -3) then begin
  129.   writeln('The prisoners are very unsatisfied , income - 25');
  130.   inc := inc - 25;
  131.   end;
  132.  
  133.   if (stats > -3) then begin
  134.   inc := 150;
  135.   end;
  136. {ending -inc routine}
  137.  
  138. {-----------------------}
  139.  
  140. {starting final question before next day}
  141.  begin
  142.   repeat
  143.   key2 := ' ';
  144.   key3 := ' ';
  145.   writeln('Continue(C) or Menu(M)? : ');
  146.   readln(key2);
  147.   key2 := upcase(key2);
  148.   until (key2 = 'C') or (key2 = 'M');
  149.  
  150.  {choice to continue or menu}
  151.  
  152.   if (key2 = 'M') then begin
  153.   repeat
  154.   writeln('You entered the Menu, what you wish to do?');
  155.   writeln('--------------------------');
  156.   writeln('(B)uy new prisoner (-300 cash);');
  157.   writeln('(I)ncrease security (- 200 cash);');
  158.   writeln('(C)ontinue ( = cash);');
  159.   readln(key3);
  160.   key3 := upcase(key3);
  161.   until (key3 = 'B') or (key3 = 'I') or (key3 = 'C');
  162.   end;
  163.   end;
  164.  {ending menu choice}
  165.  
  166.  {starting custom choice}
  167.   if (key3 = 'B') then begin
  168.   writeln('You have bought a new prisoner!');
  169.   writeln('-300 cash');
  170.   writeln('Income : + 50');
  171.   inc := inc + 50;
  172.   bank := bank - 300;
  173.   readln;
  174.   end;
  175.  
  176.   if (key3 = 'I') then begin
  177.   writeln('Security system upgraded, canche of escape decreased');
  178.   writeln('-200 cash');
  179.   bank := bank - 200;
  180.   jbc := jbc + 2;
  181.   sec := sec + 1;
  182.   readln;
  183.   end;
  184.   {ending custom choice}
  185.   {end day}
  186.  
  187. {chance of escape at night}
  188.   if (rnd2 = 1) then begin
  189.   writeln('Bad Luck!One of your prisoner escaped!');
  190.   pris := pris - 1;
  191.   inc := inc - 50;
  192.   readln;
  193.   end;
  194. {end canche}
  195.  
  196.  until (pris = 5) or (bank < -300) or (pris = 0);
  197.  
  198.   if pris = 0 then begin
  199.   writeln('You have no more prisoners, sorry, you lost the game!');
  200.   end;
  201.   if pris = 5 then begin
  202.   writeln('Congratulations! You won the game in ',turn,' days with 5 prisoners!');
  203.   end;
  204.   if bank < -300 then
  205.   writeln('Sorry, you lost the game (< -300 cash)');
  206.   end;
  207.  
  208.  
  209.   repeat
  210.   writeln('Play again? (Y/N): ');
  211.   readln(key1);
  212.   key1 := upcase(key1);
  213.   until (key = 'Y') or (key = 'N');
  214. until (key = 'N');
  215. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement