Advertisement
Alexander_Maximov

Untitled

Mar 16th, 2023
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3.  
  4. namespace GladiatorFight
  5. {
  6.     public class Fighter
  7.     {
  8.         public string Name { get; }
  9.         public int Health { get; private set; }
  10.         protected int Damage { get;}
  11.         private int _armor;
  12.  
  13.         protected Fighter(string name, int health, int damage, int armor)
  14.         {
  15.             Name = name;
  16.             Health = health;
  17.             Damage = damage;
  18.             _armor = armor;
  19.         }
  20.  
  21.         public Fighter()
  22.         {
  23.            
  24.         }
  25.  
  26.         public int GetDamage()
  27.         {
  28.             Console.Write("\nОбычная атака.");
  29.             return Damage;
  30.         }
  31.  
  32.         public void ShowFightersInfo()
  33.         {
  34.             Console.WriteLine($"Имя - {Name} | Здоровье - {Health} | Урон - {Damage} | Защита - {_armor}");
  35.         }
  36.  
  37.         public bool ShowFightersHealthInfo()
  38.         {
  39.             bool winStatus = true;
  40.  
  41.             if (Health > 0)
  42.             {
  43.                 Console.WriteLine($"У воина {Name} здоровье стало - {Health}.");
  44.             }
  45.  
  46.             else
  47.             {
  48.                 winStatus = false;
  49.                 Console.WriteLine($"У воина {Name} здоровье стало - 0");        
  50.             }
  51.            
  52.             return winStatus;
  53.         }
  54.  
  55.         public void TakeDamage(int damage)
  56.         {
  57.             Health -= damage - _armor;
  58.             Console.WriteLine();
  59.             Console.WriteLine($"{Name} получил {damage - _armor} ед. урона ({damage} - {_armor}).");
  60.         }
  61.  
  62.         public virtual int UseSkill(int roundCount)
  63.         {
  64.             int skillDamage = 0;
  65.             return skillDamage;
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement