Пример #1
0
        public static bool TurnoEroe(Eroe eroe, Mostro mostro)
        {
            //ritorna true se la battaglia è finita, ritorna false se è il turno del mostro

            Console.WriteLine("Scegli:");
            Console.WriteLine("1 - Attaccare il Mostro");
            Console.WriteLine("Premi un tasto per Tentare la fuga");

            char a = Console.ReadKey().KeyChar;

            Console.WriteLine();

            switch (a)
            {
            case '1':
                bool z = eroe.AttaccareMostro(eroe, mostro);
                if (z == true)
                {
                    Console.WriteLine("Il Mostro è morto");
                    //hai vinto la battaglia
                    eroe.PuntiAccumulati += (mostro.Livello.Num * 10);
                    //Controllo sul livello
                    eroe.LivelloID = eroe.Livello.DefinizioneLivello(eroe.PuntiAccumulati);
                    eroeservice.Update(eroe);
                    if (eroe.PuntiAccumulati >= 200)
                    {
                        //l'eroe ha vinto inserire un flag
                        eroe.Vittoria = true;
                        Console.WriteLine("Vittoria!!!!!!");
                        return(true);
                    }
                    return(true);
                }
                else
                {
                    //la battaglia continua
                    return(false);
                }

            default:
                bool x = eroe.TentareFuga();
                if (x == true)
                {
                    Console.WriteLine("Tentativo riuscito sei scappato!");
                    eroe.PuntiAccumulati -= (mostro.Livello.Num * 5);
                    //battaglia finita
                    return(true);
                }
                else
                {
                    Console.WriteLine("Tentativo fallito! Turno del Mostro");
                    return(false);
                }
            }
        }