static void Main(string[] args) { // Attacking properties for a wizard character var warriorAttackingService = new WarriorAttackingService(); var wizardAttackingService = new WizardAttackingService(); var gandalf = new WizardCharacter(wizardAttackingService); gandalf.Display(); // Attack as a wizard gandalf.Attack(); // Attack as warrior gandalf.ChangeWeapon(warriorAttackingService); gandalf.Attack(); }
public ICharacterHandler BuildCharacters(CharacterDetails details) { return(details switch { WarriorCharacter warrior => new CharacterHandler( "Warrior", _mediator, Random.Shared.Next(180, 240), new Sword(warrior.Strength), new Voice(1)), WizardCharacter wizard => new CharacterHandler( "Wizard", _mediator, Random.Shared.Next(80, 120), new Melee(5), Random.Shared.Next(1, 4) switch { 1 => new Staff(wizard.SpellPower), 2 => new Fan(wizard.SpellPower), 3 => new Rod(wizard.SpellPower), _ => throw new InvalidOperationException() }),