public void OnCastMagic(CastMagicEventArgs args) { if (this.CastMagic == null) { args.CastedWizardsIds.Add(this.Id); } else { this.CastMagic(this, args); } }
public override void Execute(string[] commandParams, IRepository repository) { var id = int.Parse(commandParams[0]); var wizard = repository.GetWizard(id); var args = new CastMagicEventArgs($"Reflection"); wizard.Cast(wizard, args); foreach (var wizardId in args.CastedWizardsIds) { repository.AddWizardClones(wizardId); } }
public void Cast(object sender, CastMagicEventArgs args) { Console.WriteLine($"{this.Name} {this.Id} casts " + string.Format(args.Expression, this.MagicalPower)); this.OnCastMagic(args); }