Advertisement
OwlyOwl

Glads_question

Jul 5th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Glads
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Rogue rogue = new Rogue(60, 9);
  11.             Paladin paladin = new Paladin(100, 6);
  12.             Vampire vampire = new Vampire(50, 10);
  13.             Druid druid = new Druid(80, 7);
  14.             Shaman shaman = new Shaman(70, 8);
  15.             List<Fighter> fighterList = new List<Fighter>();
  16.             fighterList.Add(rogue);
  17.             fighterList.Add(paladin);
  18.             fighterList.Add(vampire);
  19.             fighterList.Add(druid);
  20.             fighterList.Add(shaman);
  21.  
  22.             Console.WriteLine("Выберите бойцов (Поочередно введите две цифры):\n1 - Rogue\n2 - Paladin\n3 - Vampire\n4 - Druid\n5 - Shaman");
  23.             int userInput1 = Convert.ToInt32(Console.ReadLine());
  24.             int userInput2 = Convert.ToInt32(Console.ReadLine());
  25.             fighterList[userInput1 - 1].startFight(fighterList[userInput1 - 1], fighterList[userInput2 - 1]);
  26.         }
  27.  
  28.  
  29.         class Fighter
  30.         {
  31.             protected int Health;
  32.             protected int Damage;
  33.  
  34.             public Fighter(int health, int damage)
  35.             {
  36.                 Health = health;
  37.                 Damage = damage;
  38.             }
  39.  
  40.             public void startFight(Fighter fighter1, Fighter fighter2)
  41.             {
  42.                 Console.WriteLine("Start!");
  43.                 while (fighter1.Health >= 0 && fighter2.Health >= 0)
  44.                 {
  45.                     fighter1.TakeDamage(fighter2.Damage);
  46.                     fighter2.TakeDamage(fighter1.Damage);
  47.                     fighter1.SpecialAbility();
  48.                     fighter2.SpecialAbility();
  49.                     fighter1.ShowInfo(1);
  50.                     fighter2.ShowInfo(2);
  51.                     Console.ReadKey();
  52.                     Console.Clear();
  53.                 }
  54.                 if (fighter1.Health > 0)
  55.                 {
  56.                     Console.WriteLine("Победил первый боец!");
  57.                 }
  58.                 else
  59.                 {
  60.                     Console.WriteLine("Победил второй боец!");
  61.                 }
  62.             }
  63.  
  64.             public void TakeDamage(int damageAmount)
  65.             {
  66.                 Health -= Damage;
  67.             }
  68.  
  69.             public void SpecialAbility()
  70.             {
  71.  
  72.             }
  73.  
  74.             public void ShowInfo(int fighterNumber)
  75.             {
  76.                 Console.WriteLine($"Здоровье бойца номер: {fighterNumber} = {Health}");
  77.             }
  78.         }
  79.  
  80.         class Rogue : Fighter
  81.         {
  82.             public Rogue(int health, int damage) : base(health, damage) { }
  83.             public new void SpecialAbility()
  84.             {
  85.                 Damage += 3;
  86.             }
  87.         }
  88.  
  89.         class Paladin : Fighter
  90.         {
  91.             public Paladin(int health, int damage) : base(health, damage) { }
  92.  
  93.             public new void SpecialAbility()
  94.             {
  95.                 Health += 5;
  96.             }
  97.         }
  98.  
  99.         class Vampire : Fighter
  100.         {
  101.             public Vampire(int health, int damage) : base(health, damage) { }
  102.  
  103.             public new void SpecialAbility()
  104.             {
  105.                 Damage += 1;
  106.                 Health += 2;
  107.             }
  108.         }
  109.  
  110.         class Druid : Fighter
  111.         {
  112.             public Druid(int health, int damage) : base(health, damage) { }
  113.  
  114.             public new void SpecialAbility()
  115.             {
  116.                 if (Health <= 20)
  117.                 {
  118.                     Damage += 15;
  119.                 }
  120.             }
  121.         }
  122.  
  123.         class Shaman : Fighter
  124.         {
  125.             public Shaman(int health, int damage) : base(health, damage) { }
  126.             private bool cooldown = false;
  127.  
  128.             public new void SpecialAbility()
  129.             {
  130.  
  131.                 if (Health <= 15 && cooldown != true)
  132.                 {
  133.                     Health += 50;
  134.                     cooldown = true;
  135.                 }
  136.             }
  137.         }
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement