• 练习——对战游戏


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace 对战
    {
        class Program
        {
            static void Main(string[] args)
            {
                role rol1 = new role();
                role rol2 = new role();
                skill s1 = new skill();
                skill s2 = new skill();
                skill s3 = new skill();
                skill s4 = new skill();
                Random ran= new Random();
                Console.WriteLine("1、格罗姆  2、吉安娜  3、乌瑟尔  4、安度因");
                int r1 = 0;
                int r2 = 0;
                for (; ; )//选择角色
                {
                    try
                    {
                        Console.Write("请选择第一个角色(输入序号):");
                        int rr1 = int.Parse(Console.ReadLine());
                        if (rr1 >= 1 && rr1 <= 4)
                        {
                            r1 = rr1;
                        }
                        else
                        {
                            Console.WriteLine("请从以上四个角色之中选择!");
                            continue;
                        }
                        Console.Write("请选择第二个角色(输入序号):");
                        int rr2 = int.Parse(Console.ReadLine());
                        if (rr2 >= 1 && rr2 <= 4)
                        {
                            r2 = rr2;
                            break;
                        }
                        else
                        {
                            Console.WriteLine("请从以上四个角色之中选择!");
                            continue;
                        }
                    }
                    catch
                    {
                        Console.WriteLine("操作有误,请正确输入角色序号!");
                        continue;
                    }
                }
                //录入第一个角色信息
                if(r1==1)
                {
                    rol1.Name = "格罗姆";
                    rol1.Blood = 3000;
                    rol1.Str = 100;
                    s1.Name = "冲锋";
                    s1.Str = 200;
                    rol1.Smlski = s1;
                    s2.Name = "风车";
                    s2.Str = 500;
                    rol1.Bigski = s2;
                }
                else if (r1 == 2)
                {
                    rol1.Name = "吉安娜";
                    rol1.Blood = 1500;
                    rol1.Str = 200;
                    s1.Name = "火球术";
                    s1.Str = 400;
                    rol1.Smlski = s1;
                    s2.Name = "暴风雪";
                    s2.Str = 1000;
                    rol1.Bigski = s2;
                }
                else if (r1 == 3)
                {
                    rol1.Name = "乌瑟尔";
                    rol1.Blood = 2500;
                    rol1.Str = 90;
                    s1.Name = "圣光术";
                    s1.Str = 300;
                    rol1.Smlski = s1;
                    s2.Name = "圣疗术";
                    s2.Str = -600;
                    rol1.Bigski = s2;
                }
                else
                {
                    rol1.Name = "安度因";
                    rol1.Blood = 2000;
                    rol1.Str = 80;
                    s1.Name = "治疗术";
                    s1.Str = -200;
                    rol1.Smlski = s1;
                    s2.Name = "医疗波";
                    s2.Str = -800;
                    rol1.Bigski = s2;
                }
                //录入第二个角色信息
                if (r2 == 1)
                {
                    rol2.Name = "格罗姆";
                    rol2.Blood = 3000;
                    rol2.Str = 100;
                    s3.Name = "冲锋";
                    s3.Str = 200;
                    rol2.Smlski = s3;
                    s4.Name = "风车";
                    s4.Str = 500;
                    rol2.Bigski = s4;
                }
                else if (r2 == 2)
                {
                    rol2.Name = "吉安娜";
                    rol2.Blood = 1500;
                    rol2.Str = 200;
                    s3.Name = "火球术";
                    s3.Str = 400;
                    rol2.Smlski = s3;
                    s4.Name = "暴风雪";
                    s4.Str = 1000;
                    rol2.Bigski = s4;
                }
                else if (r2 == 3)
                {
                    rol2.Name = "乌瑟尔";
                    rol2.Blood = 2500;
                    rol2.Str = 90;
                    s3.Name = "圣光术";
                    s3.Str = 300;
                    rol2.Smlski = s3;
                    s4.Name = "圣疗术";
                    s4.Str = -600;
                    rol2.Bigski = s4;
                }
                else
                {
                    rol2.Name = "安度因";
                    rol2.Blood = 2000;
                    rol2.Str = 80;
                    s3.Name = "治疗术";
                    s3.Str = -200;
                    rol2.Smlski = s3;
                    s4.Name = "医疗波";
                    s4.Str = -800;
                    rol2.Bigski = s4;
                }
                if(rol1.Name==rol2.Name)
                {
                    rol1.Name = rol1.Name + "1";
                    rol2.Name = rol2.Name + "2";
                }
                Console.WriteLine("==========================================================");
                Console.WriteLine("角色"+"	"+"生命值"+"	"+"攻击力"+"	"+"技能1"+"	"+"技能2");
                Console.WriteLine(rol1.Name + "	" + rol1.Blood + "	" + rol1.Str + "	" + rol1.Smlski.Name + "	" + rol1.Bigski.Name);
                Console.WriteLine(rol2.Name + "	" + rol2.Blood + "	" + rol2.Str + "	" + rol2.Smlski.Name + "	" + rol2.Bigski.Name);
                Console.WriteLine("选择完毕,请按任意键开始战斗!");
                Console.ReadKey();
                //开始战斗
                for (; ; )
                {
                    //默认角色1先手攻击
                    int ran1 = ran.Next(1, 101);//判断是否释放技能
                    if(ran1<=5)//释放大技能
                    {
                        int bigstr=0;//记录大技能数值
                        //判断是否是治疗技能
                        if (rol1.Bigski.Str > 0)
                        {
                            bigstr = ran.Next(((rol1.Bigski.Str) / 10) * 8, ((rol1.Bigski.Str) / 10) * 12);
                            Console.WriteLine("【{0}】释放了☆☆☆{1}☆☆☆,对【{2}】造成了{3}点伤害,【{4}】剩余血量{5}", rol1.Name, rol1.Bigski.Name, rol2.Name, bigstr, rol2.Name, (rol2.Blood - bigstr));
                            rol2.Blood -= bigstr;
                        }
                        else
                        {
                            bigstr = ran.Next((Math.Abs(rol1.Bigski.Str) / 10) * 8, (Math.Abs(rol1.Bigski.Str) / 10) * 12);
                            Console.WriteLine("【{0}】释放了☆☆☆{1}☆☆☆,治疗了自己{2}点血量,【{3}】剩余血量{4}", rol1.Name, rol1.Bigski.Name, bigstr, rol1.Name, (rol1.Blood + bigstr));
                            rol1.Blood += bigstr;
                        }
                    }
                    else if (ran1<= 20)//释放小技能
                    {
                        int smlstr = 0;
                        if (rol1.Smlski.Str > 0)
                        {
                            smlstr = ran.Next(((rol1.Smlski.Str) / 10) * 8, ((rol1.Smlski.Str) / 10) * 12);
                            Console.WriteLine("【{0}】释放了☆{1}☆,对【{2}】造成了{3}点伤害,【{4}】剩余血量{5}", rol1.Name, rol1.Smlski.Name, rol2.Name, smlstr, rol2.Name, (rol2.Blood - smlstr));
                            rol2.Blood -= smlstr;
                        }
                        else
                        {
                            smlstr = ran.Next((Math.Abs(rol1.Smlski.Str) / 10) * 8, (Math.Abs(rol1.Smlski.Str) / 10) * 12);
                            Console.WriteLine("【{0}】释放了☆{1}☆,治疗了自己{2}点血量,【{3}】剩余血量{4}", rol1.Name, rol1.Smlski.Name, smlstr, rol1.Name, (rol1.Blood + smlstr));
                            rol1.Blood += smlstr;
                        }
                    }
                    else//不释放技能,普通攻击
                    {
                        int str = ran.Next(((rol1.Str) / 10) * 8, ((rol1.Str) / 10) * 12);
                        Console.WriteLine("【{0}】攻击了【{1}】,对【{2}】造成了{3}点伤害,【{4}】剩余血量{5}",rol1.Name,rol2.Name,rol2.Name,str,rol2.Name,(rol2.Blood-str));
                        rol2.Blood -= str;
                    }
                    Console.WriteLine();
                    if(rol2.Blood<=0)//判断是否阵亡
                    {
                        Console.WriteLine("【{0}】阵亡,【{1}】获得了胜利。",rol2.Name,rol1.Name);
                        break;
                    }
                    System.Threading.Thread.Sleep(1500);
    
                    //角色2进行攻击
                    int ran2 = ran.Next(1, 101);
                    if (ran2 <= 5)
                    {
                        int bigstr = 0;
                        if (rol2.Bigski.Str > 0)
                        {
                            bigstr = ran.Next(((rol2.Bigski.Str) / 10) * 8, ((rol2.Bigski.Str) / 10) * 12);
                            Console.WriteLine("【{0}】释放了☆☆☆{1}☆☆☆,对【{2}】造成了{3}点伤害,【{4}】剩余血量{5}", rol2.Name, rol2.Bigski.Name, rol1.Name, bigstr, rol1.Name, (rol1.Blood - bigstr));
                            rol1.Blood -= bigstr;
                        }
                        else
                        {
                            bigstr = ran.Next((Math.Abs(rol2.Bigski.Str) / 10) * 8, (Math.Abs(rol2.Bigski.Str) / 10) * 12);
                            Console.WriteLine("【{0}】释放了☆☆☆{1}☆☆☆,治疗了自己{2}点血量,【{3}】剩余血量{4}", rol2.Name, rol2.Bigski.Name, bigstr, rol2.Name, (rol2.Blood + bigstr));
                            rol2.Blood += bigstr;
                        }
                    }
                    else if (ran2 <= 20)
                    {
                        int smlstr = 0;
                        if (rol2.Smlski.Str > 0)
                        {
                            smlstr = ran.Next(((rol2.Smlski.Str) / 10) * 8, ((rol2.Smlski.Str) / 10) * 12);
                            Console.WriteLine("【{0}】释放了☆{1}☆,对【{2}】造成了{3}点伤害,【{4}】剩余血量{5}", rol2.Name, rol2.Smlski.Name, rol1.Name, smlstr, rol1.Name, (rol1.Blood - smlstr));
                            rol1.Blood -= smlstr;
                        }
                        else
                        {
                            smlstr = ran.Next((Math.Abs(rol2.Smlski.Str) / 10) * 8, (Math.Abs(rol2.Smlski.Str) / 10) * 12);
                            Console.WriteLine("【{0}】释放了☆{1}☆,治疗了自己{2}点血量,【{3}】剩余血量{4}", rol2.Name, rol2.Smlski.Name, smlstr, rol2.Name, (rol2.Blood + smlstr));
                            rol2.Blood += smlstr;
                        }
                    }
                    else
                    {
                        int str = ran.Next(((rol2.Str) / 10) * 8, ((rol2.Str) / 10) * 12);
                        Console.WriteLine("【{0}】攻击了【{1}】,对【{2}】造成了{3}点伤害,【{4}】剩余血量{5}", rol2.Name, rol1.Name, rol1.Name, str, rol1.Name, (rol1.Blood - str));
                        rol1.Blood -= str;
                    }
                    Console.WriteLine();
                    if (rol1.Blood <= 0)
                    {
                        Console.WriteLine("【{0}】阵亡,【{1}】获得了胜利。", rol1.Name, rol2.Name);
                        break;
                    }
                    System.Threading.Thread.Sleep(1500);
                }
    
                Console.ReadKey();
            }
        }
    }

  • 相关阅读:
    BeanShell实现写入文件
    LoadRunner11录制APP脚本(2)
    LoadRunner11录制APP脚本(1)
    性能测试 研究方向
    JMeter录制脚本方式(二)
    JMeter常用字符串相关函数
    JMeter中BeanShell用法总结(一)
    第二篇:JMeter实现接口/性能自动化(JMeter/Ant/Jenkins)
    第一篇:JMeter实现接口/性能自动化(JMeter/Ant/Jenkins)
    JMeter设置集合点
  • 原文地址:https://www.cnblogs.com/wt627939556/p/6104338.html
Copyright © 2020-2023  润新知