samedi 8 février 2020

C# If-loop for small console game

Hopefully you can help me! I have drawn a blank with this. I am making a small console game. I am entirely new to c#, so maybe its a dumbfound question. Ex:

If you play Ashe, and you go against Brand - I want ashe to win. I feel like i need and if-else loop but I need help writting it.

Thank you!!

class Champ
        {
            public int Health { get; set; }
            public string Ult { get; set; }
            public int Victories { get; set; }
        }

        static public void SoloFightChamps()
        {
            var Ashe = new Champ();
            var Brand = new Champ();
            var Annie = new Champ();
            var Braum = new Champ();

            Ashe.Health = 100;
            Ashe.Ult = "Ranger";

            Brand.Health = 100;
            Brand.Ult = "Assasin";

            Annie.Health = 100;
            Annie.Ult = "Fire";

            Braum.Health = 100;
            Braum.Ult = "Warrior";


            Console.WriteLine("Press enter to fight!");
            Console.ReadLine();

            var Battle = new Task(() => {
                for (int ctr = 1; ctr <= 3; ctr++)
                {
                    Console.WriteLine(" In battle {0}", ctr);

                    Task.Delay(1000).Wait();

//Code that makes Ranger win over Assasin


                }
            }
        );

            Battle.Start();
            Battle.Wait();



        }

Aucun commentaire:

Enregistrer un commentaire