From 9d936e298be8dd12168df55c7d38ab9ac587e9ff Mon Sep 17 00:00:00 2001 From: lazy3698 <2820608163@qq.com> Date: Sun, 6 Jun 2021 19:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=8B=E8=BF=9C=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Program.cs" | 220 ++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 "\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\350\277\234\346\226\271/Program.cs" diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\350\277\234\346\226\271/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\350\277\234\346\226\271/Program.cs" new file mode 100644 index 0000000..602a51f --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\350\277\234\346\226\271/Program.cs" @@ -0,0 +1,220 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace lazy +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("----------------欢迎进入游戏世界----------------"); + Console.WriteLine("*******************************"); + Console.WriteLine("********心里博弈之猜拳*********"); + Console.WriteLine("*******************************"); + Console.WriteLine("游戏规则:1、剪刀 2、石头 3、布"); + //Console.WriteLine("请输入敌方角色:1、刘备 2、孙权 3、曹操"); + //int enemy = int.Parse(Console.ReadLine()); + //Player player = new Player(); + //NPC npc01 = new NPC(); + //switch (enemy) + //{ + // case 1: + + // npc01.Name = "刘备"; + // npc01.NPCname(); + // Console.WriteLine("输入你的名字:"); + // player.Name = Console.ReadLine(); + // Console.WriteLine("{0} vs {1}", player.Name, npc01.Name); + // break; + //} + //Console.WriteLine("对决吗?"); + //string choose = Console.ReadLine(); + //switch (choose) + //{ + // case "y": + // Console.WriteLine("请出拳:1、剪刀 2、石头 3、布(输入对应数字即可)"); + // break; + //} + NPC d = new NPC(); + Player w = new Player(); + Mora m = new Mora(); + while (true) + { + bool Q = true; + d.NPCname(); + w.Playername(); + Console.WriteLine("{0} vs {1}",w.Name,d.Name); + Console.WriteLine("要开始对局吗?(y/n)"); + string yn = Console.ReadLine(); + switch (yn) + { + case "y": + m.morap(); + m.moran(); + Console.WriteLine("{0}: 出招:{1}",w.Name,m.PlayerMora); + Console.WriteLine("{0}: 出招:{1}",d.Name,m.NPCMora); + m.Theending(); + while (Q) + { + int record = 0; + record++; + Console.WriteLine("是否开始下一轮?(y/n)"); + string q = Console.ReadLine(); + switch (q) + { + case "y": + m.morap(); + m.moran(); + Console.WriteLine("{0}: 出招:{1}", w.Name, m.PlayerMora); + Console.WriteLine("{0}: 出招:{1}", d.Name, m.NPCMora); + m.Theending(); + break; + case "n": + Console.WriteLine("====================================="); + Console.WriteLine("{0} vs {1}",w.Name,d.Name); + Console.WriteLine("对战次数:" + record); + Console.WriteLine("姓名\t得分 "); + Console.WriteLine("{0}\t{1}",w.Name,m.Win1); + Console.WriteLine("{0}\t{1}",d.Name,m.Defeat1); + if (m.Win1>m.Defeat1) + { + Console.WriteLine("结果:{0}赢,{1}不行不行",w.Name,d.Name); + } + else if (m.Win1 name; set => name = value; } + public void NPCname() + { + Console.WriteLine("请选择对方角色:1、刘备2、孙权 3、曹操"); + int enemy = int.Parse(Console.ReadLine()); + switch (enemy) + { + case 1: + Name = "刘备"; + break; + case 2: + Name = "孙权"; + break; + case 3: + Name = "曹操"; + break; + + } + Console.WriteLine("我是{0}不斩无名之辈。阁下,告诉我你的名字:", Name); + } + } + class Player + { + public string name; + + public string Name { get => name; set => name = value; } + public void Playername() + { + Name =Console.ReadLine(); + } + } + class Mora + { + private string playerMora; + private string nPCMora; + private int Win = 0; + private int Defeat = 0; + private int a; + private int b; + + public string PlayerMora { get => playerMora; set => playerMora = value; } + public string NPCMora { get => nPCMora; set => nPCMora = value; } + public int A { get => a; set => a = value; } + public int B { get => b; set => b = value; } + public int Win1 { get => Win; set => Win = value; } + public int Defeat1 { get => Defeat; set => Defeat = value; } + + public void morap() + { + Console.WriteLine("请选择你的招式:1、剪刀 2、石头 3、布 <输入数字即可>"); + A = int.Parse(Console.ReadLine()); + switch (A) + { + case 1: + PlayerMora = "剪刀"; + break; + case 2: + PlayerMora = "石头"; + break; + case 3: + PlayerMora = "布"; + break; + } + } + public void moran() + { + Random random = new Random(); + B = random.Next(1, 4); + switch (B) + { + case 1: + NPCMora = "剪刀"; + break; + case 2: + NPCMora = "石头"; + break; + case 3: + NPCMora = "布"; + break; + } + } + public void Theending() + { + if (A==B) + { + Console.WriteLine("和局?你真不行。"); + } + else if (A==1 && B==3 || A==2 && B==1 || A==3 && B==2) + { + Console.WriteLine("不错,你赢了。"); + Win1++; + } + else if(B == 1 && A == 3 || B == 2 && A == 1 || B == 3 && A == 2) + { + Console.WriteLine("输的真惨!!!"); + Defeat1++; + } + } + } +} -- Gitee