Beispiel #1
0
        protected override Personaje handleRequest(string request)
        {
            Demonio demonio = new Demonio("Demonio " + this.diferenciador);

            this.diferenciador += 1;
            return(demonio);
        }
        public void Setup()
        {
            Armor armor = new Armor();
            DefaultDefenseItem defaultDefenseItem = new DefaultDefenseItem();
            Helmet             helmet             = new Helmet();
            Shield             shield             = new Shield();

            //attackItems
            Axe               axe               = new Axe();
            Bow               bow               = new Bow();
            DarkSword         darkSword         = new DarkSword();
            Sword             sword             = new Sword();
            DefaultAttackItem defaultAttackItem = new DefaultAttackItem();

            //healthItems
            Bandage bandage = new Bandage();
            CureBox cureBox = new CureBox();
            Poison  poison  = new Poison();

            //magicItems
            DefaultMagicItem defaultMagicItem = new DefaultMagicItem();
            Excalibur        excalibur        = new Excalibur();
            SpellsBook       spellsBook       = new SpellsBook();
            Spell            spell1           = new Spell();
            Spell            spell2           = new Spell();

            Staff staff = new Staff();


            //heroes
            Dwarf  dwarf  = new Dwarf("Enano", axe, helmet, shield);
            Elf    elf    = new Elf("Elfo", bow, armor, helmet);
            Knight knight = new Knight("Caballero", sword, armor, shield);
            Wizard wizard = new Wizard("Gandalf", staff, shield, armor, spellsBook);

            //villanos
            DarkWizard darkWizard = new DarkWizard("Saruman", staff, armor, spellsBook);
            Demonio    demonio    = new Demonio("Lanthos", sword, armor);
            Dragon     dragon     = new Dragon("Shiva", bow, armor);
            Orco       orco       = new Orco("Ugly", axe, helmet);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            //Se utiliza un item combinado en el demonio para probar el método
            Demonio demonio = new Demonio("Demonio");

            demonio.CombinarItems(demonio.anillo, demonio.gema);
            //Se agregan objetos para probar la excepción de si pertencian al personaje al quitarlos
            Personaje elfo   = new Elfo("Elfo");
            Personaje enano  = new Enano("Enano");
            Espada    espada = new Espada();

            elfo.AgregarObjetos(espada);
            try
            {
                elfo.Intercambiar(enano, espada);
            }
            catch (QuitarItemException e)
            {
                Console.WriteLine(e.Message);
                System.Environment.Exit(0);
            }
            enano.AgregarObjetos(espada);
            try
            {
                enano.EliminarObjetos(espada);
            }
            catch (QuitarItemException e)
            {
                Console.WriteLine(e.Message);
                System.Environment.Exit(0);
            }
            //Se crea el escenario y los handlers
            Escenario escenario = new Escenario();

            InstanciacionDeHandlers.GetInstance().Crear();
            //Se crea el input y se utiliza la excepción en caso de que haya un error al
            //ingresar la ruta del archivo
            try
            {
                IInput input = new InputTXT();
                escenario.listaCrearPersonajes = input.ProcesarArchivo();
            }
            catch (ArchivoNoEncontradoException e)
            {
                Console.WriteLine("No se encontró el archivo para procesar las encuentros, revise la ruta del mismo.");
                Console.WriteLine(e.Message);
                System.Environment.Exit(1);
            }
            try
            {
                escenario.CrearPersonajes();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                System.Environment.Exit(1);
            }
            //Se crean todas las batallas
            escenario.CrearBatallas();
            //Se crea el output
            IOutput output = new OutputTXT();

            //Se escribe la historia en el archivo
            output.EscribirArchivo(escenario.listaHistoria);
        }