一个被人写滥了的小程序,新手学习,Pascal By Chaobs

初学者可以用它来学习随机函数的运用,当然你完全可以自己写一个随机函数。

var
   player1,player2:longint;
   a,b,l,o,i,v:longint; w:boolean;
begin
   randomize;
   write('A=');readln(player1);
   write('B=');readln(player2);
   b:=1;
   i:=1;
   while(player1>0)and(player2>0)do
   begin
     if i=1 then
     begin
       a:=random(101)+1;
       if a<=70 then
       begin
         writeln('A against B,B has ',a,' damage.');
         player2:=player2-a;
       end;
       if (a>70)and(a<=80) then
       begin
         o:=random(30);
         writeln('A thumping B,B has ',a*2+o,' damage.');
         player2:=player2-a*2;
       end;
       if (a>80)and(a<=85) then
       begin
         o:=random(120);
         writeln('A restored ',a*2+o-50,' points.');
         player1:=player1+a*2+o-50;
       end;
       if (a>85)and(a<=90) then
       begin
         writeln('A launched combo. ');
         l:=100;
         w:=true;
         while w do
         begin
           o:=random(71);
           writeln('B has ',o,' damage.');
           player2:=player2-o;
           if l<random(80) then w:=false;
           l:=l-random(15);
         end;
       end;
       if (a>90)and(a<=95) then
       begin
         o:=random(300);
         writeln('A launch from exploding!');
         writeln('A has ',o div 2,' damage.');
         writeln('B has ',o+10,' damage.');
         player1:=player1-o div 2;

player2:=player2-(o+10);
       end;
       if (a>95)and(a<=97) then
       begin
         writeln('A midicine,restore ',400,' points!');
         player1:=player1+400;
       end;
       if (a>97)and(a<=100) then
       begin
         o:=random(100)+100;
         writeln('A vampire ',o,' points.');
         player1:=player1+o;
         player2:=player2-o;
       end;
       if (a=101) then
       begin
         writeln('A colossus heaven boxing! ');
         l:=100;
         o:=random(20)+1;
         for v:=1 to 100 do
         begin
           writeln('B has ',v*o,' damage.');
           player2:=player2-v*o;
           if l<random(80) then break;
           l:=l-random(15);
         end;
       end;
       i:=2;
       if player1<0 then player1:=0;
       if player2<0 then player2:=0;
       writeln('   A   ',player1);
       writeln('   B   ',player2);
       readln;
     end;
     if i=2 then
     begin
       a:=random(101)+1;
       if a<=70 then
       begin
         writeln('B against A,A has ',a,' damage.');
         player1:=player1-a;
       end;
       if (a>70)and(a<=80) then
       begin
         o:=random(30);
         writeln('B thumping A,A has ',a*2+o,' damage.');
         player1:=player1-a*2;

end;                                            
       if (a>80)and(a<=85) then
       begin
         o:=random(120);
         writeln('B restored ',a*2+o-50,' points.');
         player2:=player2+a*2+o-50;
       end;
       if (a>85)and(a<=90) then
       begin
         writeln('B launched combo. ');
         l:=100;
         w:=true;
         while w do
         begin
           o:=random(71);
           writeln('A has ',o,' damage.');
           player1:=player1-o;
           if l<random(80) then w:=false;
           l:=l-random(15);
         end;
       end;
       if (a>90)and(a<=95) then
       begin
         o:=random(300);
         writeln('B launch from exploding!');
         writeln('B has ',o div 2,' damage.');
         writeln('A has ',o+10,' damage.');
         player2:=player2-o div 2;
         player1:=player1-(o+10);
       end;
       if (a>95)and(a<=97) then
       begin
         writeln('B midicine,restore ',400,' points!');
         player2:=player2+400;
       end;
       if (a>97)and(a<=100) then
       begin
         o:=random(100)+100;
         writeln('B vampire ',o,' points.');
         player2:=player2+o;
         player1:=player1-o;
       end;
       if (a=101) then
       begin
         writeln('B colossus heaven boxing! ');
         l:=100;
         o:=random(20)+1;
         for v:=1 to 100 do
         begin
           writeln('A has ',v*o,' damage.');
           player1:=player1-v*o;
           if l<random(80) then break;
           l:=l-random(15);
         end;
       end;
       i:=1;
       if player1<0 then player1:=0;
       if player2<0 then player2:=0;
       writeln('   A   ',player1);
       writeln('   B   ',player2);
       readln;
     end;
   end;
   writeln;
   if player1>player2 then writeln('A WIN!')
   else if player2>player1 then writeln('B WIN!')
        else writeln('DRAW');
   readln;
end.

 
 

Pascal小游戏 随机函数的更多相关文章

  1. Pascal小游戏 不要消灭星星

    不要消灭星星 Pascal小游戏 Chaobs改编自pascal吧 控制台小游戏嘛,就当是练习一下结构化的写法. program wxtw; uses crt; type      zbdy=reco ...

  2. Pascal小游戏 文件的产生

    一个整人的Pascal小程序 运行之后硬盘里面会有一大堆垃圾,当然更好的方法当然不是这样做! var a,b,c,d:char;beginfor a:='0' to '9' dofor b:='0' ...

  3. Pascal小游戏 双人射击

    一个双人的游戏 Pascal源码附上 只要俩人不脑残,一下午玩不完...又是控制台游戏中的一朵奇葩. Free Pascal 射击游戏 Program shooting_game; uses crt; ...

  4. Pascal小游戏之奇葩的RPG

    Pascal吧友作品 一个小RPG Chaobs转载 varplife,plifemax,patt,pre:integer;gr,ex,exmax:integer;alife,alife1,aatt, ...

  5. Pascal小游戏 俄罗斯方块怀旧版

    俄罗斯方块怀旧版(注释版) {$APPTYPE GUI}{$MODE DELPHI}program WinPiece; usesWindows; constAppName = 'WinPiece';p ...

  6. Pascal小游戏 打飞机

    一个经典的打飞机游戏(1)Pascal代码 十分经典,有一种街机的感觉 奇葩青年的又一控制台神作. uses crt; type list=record         ty,ax:integer;  ...

  7. Pascal小游戏 井字棋

    一个很经典的井字棋游戏 Pascal源码Chaobs奉上 注意:1.有的FP版本不支持汉语,将会出现乱码.2.别想赢电脑了,平手不错了. 井字过三关: program TicTacToe; uses ...

  8. Pascal小游戏 贪吃蛇

    一段未完成的Pascal贪吃蛇 说这段代码未完成其实是没有源代码格式化,FP中一行最多只有255字符宽. uses crt; const screenwidth=50; screenheight=24 ...

  9. Pascal小游戏 俄罗斯方块

    俄罗斯方块已经成为了和“Hello World”一样的程序了吧? 不要直接复制,可能需要事先 Format. program cube;uses crt,graph,dos;var gd,gm:sma ...

随机推荐

  1. InnoDB锁演示

    create table t1( c1 int(10) unsigned not null default '0', c2 int(10) unsigned not null default '0', ...

  2. Codeforces Round #404 (Div. 2) ABC

    A. Anton and Polyhedrons Anton's favourite geometric figures are regular polyhedrons. Note that ther ...

  3. react里面Fragments的使用

    关于react Fragments,React 中一个常见模式是为一个组件返回多个元素.Fragments 可以让你聚合一个子元素列表,并且不在DOM中增加额外节点. render() { retur ...

  4. python 删除空白

    Python能够找出字符串开头和末尾多余的空白.要确保字符串末尾没有空白,可使用方法rstrip() . >>> favorite_language = 'python ' > ...

  5. MyEclipse中安装findBugs插件(摘)

    安装方法如下: 1.首先从findbugs网站下载插件:http://findbugs.sourceforge.net/downloads.html 2.将下载回来的zip包解压,得到文件夹:edu. ...

  6. ES6的数组方法之Array.from

    首先说说什么是数组:数组在类型划分上归为Object,属于比较特殊的对象,数组的索引值类似于对象的key值. 数组的几个注意点: 1.数组的长度是可读属性,不可更改,数组的长度根据索引最大值. 2.数 ...

  7. BZOJ2005: [Noi2010]能量采集(容斥原理 莫比乌斯反演)

    Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 4727  Solved: 2877[Submit][Status][Discuss] Descript ...

  8. jdbc学习笔记01

    回顾: day01-03,在上一篇文章文末 day04: 分组 group by 统计每个部门的平均工资: select deptno,avg(sal) from emp group by deptn ...

  9. mybatis的坑——不报错,就是不能committing,数据存不进数据库

    测试的时候会报空指针异常,在项目跑的时候会停止执行程序,不会出现异常. 经过一星期的排查与测试,最终找到错误,把mapper文件的映射属性名写错了. property属性名要与接收类的属性名保持一致. ...

  10. Shell 入门笔记(一)

    Shell简介 在开发过程中Linux系统经常接触和使用的,Shell 是我们用户使用 Linux 的桥梁,是C 语言编写的程序.Shell 是一种命令语言,同时一种程序设计语言.对大多数开发人员来说 ...