Advertisement
EvgeniVT

Fighter

Dec 13th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. using MortalEngines.Entities.Contracts;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5.  
  6. namespace MortalEngines.Entities
  7. {
  8.     public class Fighter : BaseMachine, IFighter
  9.     {
  10.         private const double health = 200;
  11.         private double attackPoints;
  12.         private bool aggressiveMode;
  13.  
  14.         public Fighter(string name, double attackPoints, double defensePoints) : base(name, attackPoints, defensePoints, health)
  15.         {
  16.             this.aggressiveMode = true;
  17.             this.attackPoints = attackPoints + 50;
  18.             this.DefensePoints = defensePoints - 25;
  19.         }
  20.         public override double AttackPoints => attackPoints;
  21.  
  22.         public override double DefensePoints { get; set; }
  23.  
  24.         public bool AggressiveMode => aggressiveMode;
  25.  
  26.         public void ToggleAggressiveMode()
  27.         {
  28.             this.aggressiveMode = !this.aggressiveMode;
  29.             if(this.AggressiveMode)
  30.             {
  31.                 attackPoints += 50;
  32.                 DefensePoints -= 25;
  33.             }
  34.             else
  35.             {
  36.                 attackPoints -= 50;
  37.                 DefensePoints += 25;
  38.             }
  39.         }
  40.  
  41.         public override string ToString()
  42.         {
  43.             var sb = new StringBuilder(base.ToString());
  44.             sb.AppendLine();
  45.             sb.Append($" *Aggressive: {(this.AggressiveMode ? "ON" : "OFF")}");
  46.             return sb.ToString();
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement