logancberrypie

RPG

Jun 13th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.85 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. using System.Threading;
  7.  
  8. namespace KIll_Joe
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.  
  15.             List<person> players = new List<person>();
  16.             Console.WriteLine("How many players do you want? ");
  17.             int amount = Convert.ToInt16(Console.ReadLine());
  18.  
  19.             string name;
  20.             string alergy;
  21.             int age;
  22.  
  23.             for (int i =0;i<amount;i++)
  24.             {
  25.                 Console.WriteLine("\n Infomation for player " + (i + 1));
  26.                 Console.WriteLine("Enter name ");
  27.                 name = Console.ReadLine();
  28.                 Console.WriteLine("Enter age");
  29.                 age = Convert.ToInt16(Console.ReadLine());
  30.                 Console.WriteLine("Enter alegergy");
  31.                 alergy = Console.ReadLine();
  32.                 players.Add(new person(name, age, alergy));
  33.             }
  34.  
  35.  
  36.  
  37.             person ben = new person("Ben", 17, "Apples");
  38.             person joe = new person("Joe", 17, "Apples");
  39.             ben.attack(joe);
  40.  
  41.  
  42.  
  43.             Console.ReadLine();
  44.  
  45.         }
  46.     }
  47.  
  48.     class person
  49.     {
  50.         Random random = new Random();
  51.  
  52.         static public int hp = 100;
  53.         static public bool alive = true;
  54.  
  55.         private string name;
  56.         private string allergy;
  57.  
  58.         private int age;
  59.         private int attackStrenght;
  60.         private int soak;
  61.  
  62.  
  63.  
  64.  
  65.         public person(string name,int age,string allergy)
  66.         {
  67.             this.name = name;
  68.             this.age = age;
  69.             this.attackStrenght = random.Next() % 200;
  70.             Console.WriteLine("Attack strenght is " + attackStrenght);
  71.             this.allergy = allergy;
  72.             this.soak = random.Next() % 25;
  73.             Console.WriteLine("Soak is " + attackStrenght);
  74.         }
  75.         public void dead()
  76.         {
  77.             Console.WriteLine(name+" has died");
  78.             alive = false;
  79.             output_stats();
  80.         }
  81.        
  82.         public int getHp()
  83.         {
  84.             return hp;
  85.         }
  86.         public void ChangeHp(int newHp)
  87.         {
  88.             hp = newHp;
  89.         }
  90.  
  91.         public void attack(person enemy)
  92.         {
  93.             Console.WriteLine(name + " is attacking " + enemy.name);
  94.             if (attackStrenght >= enemy.soak)
  95.             {
  96.                 enemy.ChangeHp(enemy.getHp() - (attackStrenght - enemy.soak));
  97.             }
  98.             if (enemy.getHp() <= 0)
  99.             {
  100.                 enemy.dead();
  101.             }
  102.             enemy.output_stats();
  103.         }
  104.        
  105.  
  106.         public void eat_food(string food)
  107.         {
  108.            
  109.             if (food == allergy)
  110.             {
  111.                 Console.WriteLine("Urrrr.....That thats worse than a democrat");
  112.                
  113.                 hp -= random.Next() % hp;
  114.             }
  115.             else
  116.             {
  117.                 Console.WriteLine("Mmmm.......that tastes better than a republican");
  118.                 hp += random.Next() % (hp / 2);
  119.             }
  120.             output_stats();
  121.         }
  122.  
  123.         public void output_stats()
  124.         {
  125.             Console.WriteLine("\n\n\n");
  126.             Console.WriteLine("..............................................");
  127.             Console.WriteLine("..........Stats...............................");
  128.             Console.WriteLine("Name :.................................. " + name);
  129.             Console.WriteLine("Age :.................................. " + age);
  130.             Console.WriteLine("Hp :.................................. " + hp);
  131.             Console.WriteLine("Allergy :.................................. " + allergy);
  132.             Console.WriteLine("Attack Strnenght :.................................. " + attackStrenght);
  133.  
  134.         }
Advertisement
Add Comment
Please, Sign In to add comment