Ejemplo n.º 1
0
 public void Attaquer(MonstreFacile target)
 {
     if (this.LanceDeDe() >= target.LanceDeDe())
     {
         target.EstVaincu();
     }
 }
Ejemplo n.º 2
0
        private static void Jeu1()
        {
            Hero hero = new Hero(150);
            int  monstreVaincuTotal     = 0;
            int  monstreVaincuFacile    = 0;
            int  monstreVaincuDifficile = 0;

            Console.WriteLine("Notre hero commence son combat contre la horde !");
            while (hero.EstVivant)
            {
                MonstreFacile mechant = CreateMonster();
                Console.WriteLine($"Un monstre de niveau {mechant.Type} apparait !");
                while (mechant.EstVivant)
                {
                    Console.WriteLine("Le hero s'élance et frappe !");
                    hero.Attaquer(mechant);
                    if (mechant.EstVivant)
                    {
                        Console.WriteLine("Le hero manque son coup ! L'ennemi se prepare à attaquer...");
                        mechant.Attaquer(hero);
                        if (!hero.EstVivant)
                        {
                            break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Notre combattant d'elite ne fait qu'une bouché du vile monstre !");
                    }
                }
                if (mechant is MonstreDifficile)
                {
                    monstreVaincuDifficile++;
                }
                else
                {
                    monstreVaincuFacile++;
                }
                monstreVaincuTotal++;
            }
            Console.WriteLine($"Notre Hero meurt des suites de ses blessures. Il aura vaincu {monstreVaincuTotal} monstres avant de rendre l'âme dont {monstreVaincuDifficile} monstres difficle et {monstreVaincuFacile} monstres facile :( RIP");
        }