Guest User

Untitled

a guest
Oct 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Grad
  4. {
  5.     class MainClass
  6.     {
  7.         //Int
  8.         public static int hpp = 100;
  9.         public static int gold = 50;
  10.         public static int goldground = 0;
  11.         public static int ggamountv = 0;
  12.         public static int sword = 0;
  13.         public static int swordground = 0;
  14.         public static int potions = 3;
  15.         public static int potionground = 0;
  16.         public static int inbattle = 0;
  17.         public static int monstercheck;
  18.  
  19.         //Strings
  20.         public static String name = "N/A";
  21.         public static String command = "N/A";
  22.         public static String monster = "N/A";
  23.  
  24.         //Objects
  25.         public static Random ggamount = new Random();
  26.         public static Random inbattleq = new Random();
  27.         public static Random goldgroundq = new Random();
  28.  
  29.         public static void Main(string[] args)
  30.         {
  31.             Console.Write("Pardon me, what’s your name? ");
  32.  
  33.             name = Console.ReadLine();
  34.  
  35.             Console.WriteLine("\n Ahh, welcome " + name + ".");
  36.             Console.WriteLine("Welcome to the world of Grad. In this game you loot, and fight your way out.");
  37.             Console.WriteLine("Good luck.");
  38.             System.Threading.Thread.Sleep(6000);
  39.             Console.Clear();
  40.  
  41.             while (true)
  42.             {
  43.                 Console.Title = "Grad! Player:[" + name + "] HP:[" + hpp + "] Gold:[" + gold + "] Sword:[" + sword + "] Potions:[" + potions + "]";
  44.                 inbattle = inbattleq.Next(0, 2);
  45.                 Console.Write("Command: ");
  46.                 command = Console.ReadLine();
  47.  
  48.                 if (command == "attack")
  49.                 {
  50.                     if (sword == 1 && inbattle == 0)
  51.                     {
  52.                         Console.WriteLine("You swing your sword in the air like an idiot.");
  53.                     }
  54.                     if (inbattle == 1 && sword == 1)
  55.                     {
  56.                         ReturnMonster();
  57.                         Console.WriteLine("A " + monster + " attacked!");
  58.                     }
  59.                     if (sword == 0)
  60.                     {
  61.                         Console.WriteLine("You do not have a sword.");
  62.                     }
  63.                 }
  64.  
  65.                 if (command == "exit")
  66.                 {
  67.                     Console.WriteLine("May your journey bring good fortune...");
  68.                     System.Threading.Thread.Sleep(1500);
  69.                     Environment.Exit(1);
  70.                 }
  71.  
  72.                 if (command == "help")
  73.                 {
  74.                     Console.WriteLine("Your commands are:");
  75.                     Console.WriteLine("attack, exit, potion, shop, pickup");
  76.                     if (sword == 0)
  77.                     {
  78.                         Console.WriteLine("You do not have a sword. You should buy one or you will die painfully.");
  79.                     }
  80.                 }
  81.  
  82.                 if (command == "drop")
  83.                 {
  84.                     if (sword == 0)
  85.                     {
  86.                         Console.WriteLine("You do not have a sword.");
  87.                     }
  88.                     else
  89.                     {
  90.                         Console.WriteLine("You are stupid to drop your sword. But, whatever you wish.");
  91.                         sword = 0;
  92.                         swordground = 1;
  93.                     }
  94.                 }
  95.  
  96.                 if (command == "pickup")
  97.                 {
  98.                     goldground = goldgroundq.Next(0, 2);
  99.  
  100.                     if (swordground == 1)
  101.                     {
  102.                         sword = 1;
  103.                         swordground = 0;
  104.                     }
  105.                     else if (goldground == 1)
  106.                     {
  107.                         Console.WriteLine("You picked up some gold!");
  108.                         gold = gold + ggamount.Next(1, 21);
  109.                         goldground = 0;
  110.                     }
  111.                     else if (potionground == 1)
  112.                     {
  113.                         potions = potions + 1;
  114.                         potionground = 0;
  115.                     }
  116.                     else
  117.                     {
  118.                         Console.WriteLine("There is nothing to pickup.");
  119.                     }
  120.                 }
  121.  
  122.                 if (command == "potion")
  123.                 {
  124.                     hpp += 10;
  125.                     potions--;
  126.                 }
  127.  
  128.                 if (command == "shop")
  129.                 {
  130.                     //This is temporary and will be edited.
  131.                     Console.WriteLine("A sword is 20 gold. A potion is 10 gold.");
  132.                     command = Console.ReadLine();
  133.  
  134.                     if (command == "sword")
  135.                     {
  136.                         if (gold > 19)
  137.                         {
  138.                             Console.WriteLine("You purchased a sword.");
  139.                             sword = 1;
  140.                             gold -= 20;
  141.                         }
  142.                     }
  143.  
  144.                     if (command == "potion")
  145.                     {
  146.                         if (gold > 9)
  147.                         {
  148.                             Console.WriteLine("You purchased a potion.");
  149.                             potions += 1;
  150.                             gold -= 10;
  151.                         }
  152.  
  153.                         else
  154.                         {
  155.                             Console.WriteLine("You do not have enough Gold for that.");
  156.                         }
  157.  
  158.                     }
  159.                 }
  160.             }
  161.         }
  162.  
  163.         // Function to get a random monster to encounter.
  164.         public static void ReturnMonster()
  165.         {
  166.             Random r = new Random();
  167.             monstercheck = r.Next(0, 4);
  168.             if (monstercheck == 1)
  169.             {
  170.                 monster = "Pikachu";
  171.             }
  172.             if (monstercheck == 2)
  173.             {
  174.                 monster = "Derp";
  175.             }
  176.             if (monstercheck == 3)
  177.             {
  178.                 monster = "Dick";
  179.             }
  180.             if (monstercheck == 0)
  181.             {
  182.                 monster = "Pikatit";
  183.             }
  184.         }
  185.     }
  186. }
Add Comment
Please, Sign In to add comment