一个被人写滥了的小程序,新手学习,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. IOS item属性总结

    一.UINavigationItem1> 获得方式self.navigationItem // self是指控制器 2> 作用可以用来设置当前控制器顶部导航栏的内容// 设置导航栏中间的内 ...

  2. 【转】关于Eclipse创建Android项目时,会多出一个appcompat_v7的问题

    问题描述: 使用eclipse创建一个Android项目时,发现project列表中会多创建出一个appcompat_v7项目,再创建一个Android项目时,又会再多出一个appcompat_v7_ ...

  3. Python实现接口测试中的常见四种Post请求数据

    前情: 在日常的接口测试工作中,模拟接口请求通常有两种方法, 利用工具来模拟,比如fiddler,postman,poster,soapUI等 利用代码来模拟,使用到一些网络模块,比如HttpClie ...

  4. prepareStatament和Statement和callableStatement的区别

    关系与区别 Statement.PreparedStatement和CallableStatement都是接口(interface) Statement 1.Statement接口提供了执行语句和获取 ...

  5. YSlow的安装与说明文档

    yslow官网 http://yslow.org/ 很明显起这个名字是说why slow 为什么这么慢,理所当然是为当前网页进行检测 借百度的 什么是YSlow? YSlow是yahoo发布的一款基于 ...

  6. java设计模式——迭代器模式

    一. 定义与类型 定义:提供一种方法,顺序访问一个集合对象中的各个元素,而又不暴露该对象的内部表示 类型:行为型. 二. 使用场景 (1) 访问一个集合对象的内容而无需暴露它的内部表示 (2)  为遍 ...

  7. 第二天了,由于博主太分心了,看看就跑去研究了一下ssh和ufw以及nmap,现在急需记录一下啦,哈哈!

    昨天看到了视频的ssh远程连接,因为我点电脑上装的是一个ubuntu的虚拟机,我根据视频看了一下,自己又试用了一下,我发现自己的ubuntu是能够远程到自己的Mac电脑上,一开始主要是因为自己不能连接 ...

  8. 一些简单的Js代码的封装

    1 function getById(id) { 2 3 } 4 5 function getAttr(el, k) { 6 7 } 8 9 function setAttr(el, k, v) { ...

  9. TSMessages,非HUD风格的iOS提示框(附官方demo BUG修复方案)

    优势 先看效果 个人觉得这种提示效果用在UITableView上要比HUD优雅美观,而其他情况下的提示,用HUD比较好 源码简介易懂,用起来也很方便 导入 pod导入相对很简单,主要讲怎么手动导入这个 ...

  10. Java分享笔记:FileOutputStream流的write方法

    /*------------------------ FileOutputStream: ....//输出流,字节流 ....//write(byte[] b)方法: 将b.length个字节从指定字 ...