Nasamos

Simple RPS in C# Console

Jul 22nd, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int Keuze = 0;
  14.             string KeuzeString = "";
  15.             string CPUKeuzeString = "";
  16.             int Win = 0;
  17.             int Gelijk = 0;
  18.             int Verloren = 0;
  19.  
  20.             goto Menu;
  21.  
  22.         Menu:
  23.             Keuze = 0;
  24.             Console.Clear();
  25.             Console.WriteLine("Hello, what do you wish to do?");
  26.             Console.WriteLine("1 = Play, 2 = Scores, 3 = Exit");
  27.             string EersteInput = Console.ReadLine();
  28.  
  29.             if (EersteInput == "1")
  30.             {
  31.                 goto StartSpel;
  32.             } else if (EersteInput == "2")
  33.             {
  34.                 goto Scores;
  35.             } else if (EersteInput == "3")
  36.             {
  37.                 goto SluitApp;
  38.             } else
  39.             {
  40.                 goto Menu;
  41.             }
  42.  
  43.         StartSpel:
  44.             Console.Clear();
  45.             Random RandomNum = new Random();
  46.             int CPUKeuze = RandomNum.Next(1, 4);
  47.  
  48.             if (CPUKeuze == 1)
  49.             {
  50.                 CPUKeuzeString = "Scissors";
  51.             } else if (CPUKeuze == 2)
  52.             {
  53.                 CPUKeuzeString = "Stone";
  54.             } else if (CPUKeuze == 3)
  55.             {
  56.                 CPUKeuzeString = "Paper";
  57.             }
  58.             //1 == schaar, 2 == steen, 3 == papier
  59.             //1 ^ 3, 2 ^ 1, 3 ^ 2, 1 == 1, 2 == 2, 3 = 3
  60.             Console.WriteLine("Choose: 1 = Scissors, 2 = Rock, 3 = Paper");
  61.             string DerdeKeuze = Console.ReadLine();
  62.             Console.WriteLine("");
  63.             if (DerdeKeuze == "1")
  64.             {
  65.                 Keuze = 1;
  66.                 KeuzeString = "Scissors";
  67.                 goto TweedeFase;
  68.             } else if (DerdeKeuze == "2")
  69.             {
  70.                 Keuze = 2;
  71.                 KeuzeString = "Stone";
  72.                 goto TweedeFase;
  73.             } else if (DerdeKeuze == "3")
  74.             {
  75.                 Keuze = 3;
  76.                 KeuzeString = "Paper";
  77.                 goto TweedeFase;
  78.             } else
  79.             {
  80.                 goto StartSpel;
  81.             }
  82.  
  83.         TweedeFase:
  84.             Console.Clear();
  85.             Console.WriteLine("You chose: {0}, the CPU chose: {1}",KeuzeString, CPUKeuzeString);
  86.  
  87.             if (Keuze == CPUKeuze)
  88.             {
  89.                 Console.WriteLine("It's a tie.");
  90.                 Console.WriteLine("Do you wish to play again? 1 = Menu, 2 = Exit");
  91.                 string VierdeKeuze = Console.ReadLine();
  92.                 Gelijk += 1;
  93.                 if (VierdeKeuze == "1")
  94.                 {
  95.                     goto Menu;
  96.                 }
  97.                 else if (VierdeKeuze == "2")
  98.                 {
  99.                     goto SluitApp;
  100.                 }
  101.             }
  102.             if (CPUKeuze == 1)
  103.             {
  104.                 if (Keuze == 3)
  105.                 {
  106.                     Console.WriteLine("CPU wins. (CPU: {0}, P1: {1})", CPUKeuzeString, CPUKeuzeString);
  107.                     Console.WriteLine("Do you wish to play again? 1 = Menu, 2 = Exit");
  108.                     string VierdeKeuze = Console.ReadLine();
  109.                     Verloren += 1;
  110.                     if (VierdeKeuze == "1")
  111.                     {
  112.                         goto Menu;
  113.                     }
  114.                     else if (VierdeKeuze == "2")
  115.                     {
  116.                         goto SluitApp;
  117.                     }
  118.                 }
  119.                 else
  120.                 {
  121.                     Console.WriteLine("Player wins. (P1: {0}, CPU: {1})", KeuzeString, CPUKeuzeString);
  122.                     Console.WriteLine("Do you wish to play again? 1 = Menu, 2 = Exit");
  123.                     string VierdeKeuze = Console.ReadLine();
  124.                     Win += 1;
  125.                     if (VierdeKeuze == "1")
  126.                     {
  127.                         goto Menu;
  128.                     }
  129.                     else if (VierdeKeuze == "2")
  130.                     {
  131.                         goto SluitApp;
  132.                     }
  133.                 }
  134.             }
  135.             if (CPUKeuze == 2)
  136.             {
  137.                 if (Keuze == 1)
  138.                 {
  139.                     Console.WriteLine("CPU wins. (CPU: {0}, P1: {1})", CPUKeuzeString, CPUKeuzeString);
  140.                     Console.WriteLine("Do you wish to play again? 1 = Menu, 2 = Exit");
  141.                     string VierdeKeuze = Console.ReadLine();
  142.                     Verloren += 1;
  143.                     if (VierdeKeuze == "1")
  144.                     {
  145.                         goto Menu;
  146.                     }
  147.                     else if (VierdeKeuze == "2")
  148.                     {
  149.                         goto SluitApp;
  150.                     }
  151.                 } else
  152.                 {
  153.                     Console.WriteLine("Player wins. (P1: {0}, CPU: {1})", KeuzeString, CPUKeuzeString);
  154.                     Console.WriteLine("Do you wish to play again? 1 = Menu, 2 = Exit");
  155.                     string VierdeKeuze = Console.ReadLine();
  156.                     Win += 1;
  157.                     if (VierdeKeuze == "1")
  158.                     {
  159.                         goto Menu;
  160.                     } else if (VierdeKeuze == "2")
  161.                     {
  162.                         goto SluitApp;
  163.                     }
  164.                 }
  165.             }
  166.             if (CPUKeuze == 3)
  167.             {
  168.                 if (Keuze == 2)
  169.                 {
  170.                     Console.WriteLine("CPU wins. (CPU: {0}, P1: {1})", CPUKeuzeString, CPUKeuzeString);
  171.                     Console.WriteLine("Do you wish to play again? 1 = Menu, 2 = Exit");
  172.                     string VierdeKeuze = Console.ReadLine();
  173.                     Verloren += 1;
  174.                     if (VierdeKeuze == "1")
  175.                     {
  176.                         goto Menu;
  177.                     }
  178.                     else if (VierdeKeuze == "2")
  179.                     {
  180.                         goto SluitApp;
  181.                     }
  182.                 } else
  183.                 {
  184.                     Console.WriteLine("Player wins. (P1: {0}, CPU: {1})", KeuzeString, CPUKeuzeString);
  185.                     Console.WriteLine("Do you wish to play again? 1 = Menu, 2 = Exit");
  186.                     string VierdeKeuze = Console.ReadLine();
  187.                     Win += 1;
  188.                     if (VierdeKeuze == "1")
  189.                     {
  190.                         goto Menu;
  191.                     }
  192.                     else if (VierdeKeuze == "2")
  193.                     {
  194.                         goto SluitApp;
  195.                     }
  196.                 }
  197.             }
  198.  
  199.  
  200.         Scores:
  201.             Console.Clear();
  202.             Console.WriteLine("Wins: {0}, Losses: {1}, Draws: {2}", Win, Verloren, Gelijk);
  203.             Console.WriteLine("What do you want to do? 1 = Main Menu, 2 = Exit");
  204.             string KeuzeTwee = Console.ReadLine();
  205.  
  206.             if (KeuzeTwee == "1")
  207.             {
  208.                 goto Menu;
  209.             } else if (KeuzeTwee == "2")
  210.             {
  211.                 goto SluitApp;
  212.             } else
  213.             {
  214.                 goto Scores;
  215.             }
  216.  
  217.         SluitApp:
  218.             System.Environment.Exit(1);
  219.         }
  220.     }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment