Advertisement
social1986

Untitled

Apr 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1.  public string Attack(string[] args)
  2.     {
  3.         var atackerName = args[0];
  4.         var receiverName = args[1];
  5.  
  6.         Character atacker = null;
  7.         Character receiver = null;
  8.  
  9.         if (IsCharacterOnTheParty(atackerName) || IsCharacterOnTheParty(receiverName))
  10.         {
  11.             atacker = GetCharacter(atackerName);
  12.             receiver = GetCharacter(receiverName);
  13.  
  14.             IAttackable atackingCharacter = null;
  15.  
  16.             if (CanTheCharacterAtack(atacker, atackingCharacter))
  17.             {
  18.                 atackingCharacter.Attack(receiver);
  19.             }
  20.         }
  21.     }
  22.  
  23.  private bool CanTheCharacterAtack(Character atacker, IAttackable atackingCharacter)
  24.     {
  25.         if (!(atacker is IAttackable attCharacter))
  26.         {
  27.             throw new ArgumentException(string.Format(OutputMessages.AtackerCannotAtack, atacker.Name));
  28.         }
  29.         atackingCharacter = attCharacter;
  30.         return true;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement