public static void Main() { var casterInfo = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ICast wizzard = new Wizard(casterInfo[0], int.Parse(casterInfo[1])); CasterRepository.AddCaster(wizzard); var input = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); while (!input[0].Equals("END")) { var caster = CasterRepository.GetCaster(int.Parse(input[0])); switch (input[1]) { case "FIREBALL": caster.CastFireball(null, EventArgs.Empty); break; case "REFLECTION": caster.CastReflection(null, EventArgs.Empty); break; } input = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); } }
public void CastReflection(object sender, EventArgs eventArgs) { Console.WriteLine($"{this.name} {this.Id} casts Reflection"); if (this.reflections.Count == 0) { for (int i = 0; i < MaxNumberOfReflections; i++) { idCounter++; var newReflection = new Reflection(this.name, this.spellPower / 2); this.CastReflectionEvent += newReflection.CastReflection; this.CastFireballEvent += newReflection.CastFireball; this.reflections.Add(newReflection); CasterRepository.AddCaster(newReflection); } } else { this.CastReflectionEvent?.Invoke(null, EventArgs.Empty); } }