protected void PrintHealedMessage(object sender, FighterHealedEventArgs e) { IFighter senderAsFighter = sender as IFighter; if (senderAsFighter == null) { throw new ArgumentException("BattleManagerScreenOutputs.PrintHealedMessage should subscribe to IFighters and nothing else"); } var output = e.IsFullHeal ? $"{senderAsFighter.DisplayName}'s HP was fully restored!" : $"{senderAsFighter.DisplayName} was healed for {e.HealAmount} HP!"; _output.WriteLine(output); }
public int Heal(int amount, bool isFullHeal = false) { var prevHealth = CurrentHealth; int healAmount = 0; if (CurrentHealth > 0) { CurrentHealth += amount; if (CurrentHealth > MaxHealth) { CurrentHealth = MaxHealth; } healAmount = CurrentHealth - prevHealth; FighterHealedEventArgs e = new FighterHealedEventArgs(healAmount, isFullHeal); OnHealed(e); } return(healAmount); }
private void _logHealed(object sender, FighterHealedEventArgs e) { Logs.Add(new EventLog(EventType.Healed, sender, e)); }
public void OnHealed(FighterHealedEventArgs e) { Healed?.Invoke(this, e); }