/// <summary> /// Construcción de los personajes mediante interacción por /// la terminal. /// /// La función termina cuando la entrada de usuario es vacía. /// </summary> protected virtual void BuildCharacters() { Character Nico = new Elf("Nico"); Character Mateo = new Dwarve("Mateo"); Character Diego = new Wizard("Diego"); Character Anto = new Troll("Anto"); List <Character> listaCaracteres = new List <Character>(); listaCaracteres.Add(Nico); listaCaracteres.Add(Mateo); listaCaracteres.Add(Diego); listaCaracteres.Add(Anto); Array cantidadItems = Enum.GetValues(typeof(ItemType)); Random items = new Random(); foreach (Character personaje in listaCaracteres) { int randomItem = items.Next(0, cantidadItems.Length); ItemType tipo = this.ReadItemType(); IItem item = ItemFactory.GetItem(tipo); personaje.AddItem(item); this.characters.Add(personaje); Console.WriteLine($"Built {personaje}"); } CharacterType type = this.ReadCharacterType(); while (type != default(CharacterType)) { string name = this.ReadCharacterName(); if (name == "") { name = $"The {type}"; } List <IItem> items = this.ReadCharacterItems(); Character character = CharacterFactory.GetCharacter(type, name); character.AddItems(items); this.characters.Add(character); Console.WriteLine($"Built {character}"); type = this.ReadCharacterType(); } }
static void Main(string[] args) { // IScenario scenario = new ConsoleScenario(); // scenario.Setup(); // scenario.Run(); Elf elfo = new Elf("El Elfo"); Wizard wizard = new Wizard("El Mago"); Troll troll = new Troll("El Troll"); Coraza coraza = new Coraza(); Cuchillo cuchillo = new Cuchillo(); Magic magic = new Magic(); Martillo martillo = new Martillo(); Palo palo = new Palo(); Rifle rifle = new Rifle(); RifleConCuchillo rifleConCuchillo = new RifleConCuchillo(); Robes robes = new Robes(); List<IGema> Gemas = new List<IGema>(); Gemas.Add(new GemaAmarilla()); Gemas.Add(new GemaCeleste()); Gemas.Add(new GemaRoja()); GuanteDePoder guanteDePoder = new GuanteDePoder(Gemas); elfo.AddItem(magic); elfo.AddItem(robes); wizard.AddItem(guanteDePoder); troll.AddItem(rifleConCuchillo); AttackEncounter attackEncounter = new AttackEncounter(elfo,wizard); ConsoleReporter consoleReporter = new ConsoleReporter(); attackEncounter.Reporter = consoleReporter; attackEncounter.DoEncounter(); AttackEncounter attackEncounter1 = new AttackEncounter(wizard, troll); attackEncounter1.Reporter = consoleReporter; attackEncounter1.DoEncounter(); }